Nginx 配置了 https 后就返回 302 错误,自己捣鼓了快三天了,还不解决不了,请教一下各位。

apgeypeu · October 04, 2017 · Last by bajiudongfeng replied at October 05, 2017 · 12523 hits
#server
#   {
#   listen 80;
#   server_name www.test.com test.com;
#   return 301 https://$server_name$request_uri;
#   
#}




server {
#   listen 80;
    listen 443 ssl;
    server_name www.test.com test.com;
    index index.htm index.php index.html;
    root /home/www/test;
    ssl on; 

    ssl_certificate /etc/nginx/conf.d/cert/ssl.pem;
    ssl_certificate_key /etc/nginx/conf.d/cert/ssl.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    include enable-php5.conf;


    location /nginx_status {
        stub_status on;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
           deny all;
        }
    location /{
            if (!-e $request_filename){
             rewrite ^/(.*)$ /index.php?s=$1 last;
            }
        }
    access_log /home/wwwlogs/test001.log;
}

删掉第二个 listen 80 看看

应该监听 443 端口,80 端口重定向到 https 域名,还要设置加密证书,你提供的信息很不全。

少了这个 ssl_dhparam

You need to Sign in before reply, if you don't have an account, please Sign up first.