0

i am trying to configure ssl on nginx server but it show me the wrong directory.. http on port 80 is ok, https on 443 no

this is my formazioneturismo.com.vhost

fastcgi_cache_path /var/nginx-cache/formazioneturismo.com levels=1:2 keys_zone=$

server {
    listen 443 ssl;
    server_name formazioneturismo.com www.formazioneturismo.com;
    ssl_certificate /etc/nginx/ssl/formazioneturismo.crt;
    ssl_certificate_key /etc/nginx/ssl/server.key;

    return 301 https://www.formazioneturismo.com$request_uri;
}

server {
    listen *:80;

    server_name formazioneturismo.com www.formazioneturismo.com;

    root   /var/www/formazioneturismo.com/web;
    index index.php;

    error_log /var/www/formazioneturismo.com/log/error.log;

    location ~ /\. {
        deny  all;
        access_log off;
        log_not_found off;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        access_log off;
        log_not_found off;
    }

    set $skip_cache 0;

    if ($request_method = POST) {
            set $skip_cache 1;
    }

    if ($query_string != "") {
            set $skip_cache 1;
    }

    if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|sitemap$
            set $skip_cache 1;
    }

    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wor$
            set $skip_cache 1;
    }

    location / {
            try_files $uri $uri/ /index.php?$args;

            proxy_read_timeout 300;
    }

    location ~ \.php$ {
        try_files /554f0f259d7888e056db62d833113342.htm @php;
    }

    location @php {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/lib/php5-fpm/web1.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;

        fastcgi_cache_bypass $skip_cache;
        fastcgi_no_cache $skip_cache;

        fastcgi_cache WORDPRESS_formazioneturismo.com;
        fastcgi_cache_valid  1440m;

    }

    location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jp$
            access_log off; log_not_found off; expires max;
    }
}

As you can check going to http://www.formazioneturismo.com you normally see the website, if you go to https://www.formazioneturismo.com i see the default nginx page

2 Answers 2

0

Please set the document root for listen Port 443 also I can see http location block pointed to /var/www/formazioneturismo.com/web and https block may be default to the path /var/www/formazioneturismo.com:

 server {
 listen 443 ssl;
 server_name formazioneturismo.com www.formazioneturismo.com;
 root   /var/www/formazioneturismo.com/web;
 ssl_certificate /etc/nginx/ssl/formazioneturismo.crt;
 ssl_certificate_key /etc/nginx/ssl/server.key;

Do Restart

sudo service nginx restart
1
  • root /var/www/formazioneturismo.com/web/test/; + service nginx restart ** done but the problem reimain Jan 22, 2016 at 15:03
0

I know this is a year and a half old question, but it was never properly answered and I know this - as I just ran across this very question searching this very problem. However because of this question I was instantly able to find and fix the problem.

fastcgi_cache_path /var/nginx-cache/formazioneturismo.com levels=1:2 keys_zone=$

That is the problem. This basically (I am guessing I found the docs very confusing on this) means "use zone level 1 for http" and "use zone level 2 for https" (at least thats how I translated it in my head). Switching it to levels = 2 fixed the problem.

fastcgi_cache_path /var/nginx-cache/formazioneturismo.com levels=2 keys_zone=$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .