osal adlı üyeden alıntı: mesajı görüntüle
Nginx ile site.com -> www.site.com şeklinde www eklenerek çalıştırmak istiyorum nasıl yapabilirim?

server {
    server_name site.com www.site.com;
    root /var/www/address/public_html;
    index index.php index.html;
    listen 80;
...
edit: Aşağıdaki şekilde yapınca çalıştı ama doğru bir yöntem midir?
server {
    server_name  site.com;
    rewrite ^(.*) https://www.site.com$1 permanent;
}

server {
    server_name site.com www.site.com;
    root /var/www/address/public_html;
    index index.php index.html;
    listen 80;
...
Birde bunu denermisin?

server {
    server_name  www.site.com  site.com;
    root /var/www/address/public_html;
    index index.php index.html;
    listen 80;
    access_log /var/log/nginx/site.log;   
    
    
    if ($host ~ ^site.com) {
       rewrite ^(.*) http://www.site.com$1 permanent;
    }
 
 
    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 2;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_min_length 0;
    gzip_types text/plain application/javascript text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype;
    client_body_buffer_size 10K;
    client_header_buffer_size 1k;
    client_max_body_size 8m;
    large_client_header_buffers 4 4k;
    proxy_connect_timeout 3600;
    proxy_send_timeout 3600;
    proxy_read_timeout 3600;
    send_timeout 3600;
         
    location /image/data {
        autoindex on;
    }
    location /admin {
        index index.php;
    }
    location / {
        try_files $uri [MENTION=75541]opencart[/MENTION];
     
    }
    location [MENTION=75541]opencart[/MENTION] {
        rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    
    location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
        deny all;
    }
    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }
    location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
        expires max;
        log_not_found off;
    }
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}