在https设置后,Nginx重定向到默认欢迎页面

时间:2014-07-13 01:55:53

标签: ssl nginx spdy

我在我的Nginx实例上配置了SPDY,并使用http://spdycheck.org/确认其设置,但由于一些奇怪的原因,Nginx将https重定向到默认的Nginx页面,我已从网站删除了默认的符号链接 - 启用,重新启动服务器但问题仍然存在。我的网站conf文件有:

server {
       listen 443 spdy ssl;
       server_name foobar;
       ssl_certificate /etc/nginx/ssl/server.crt;
       ssl_certificate_key /etc/nginx/ssl/server.key;
}


server {
        listen 80;
        server_name foobar;
        return 301 https://sub.foobar.com$request_uri;
        #error_page  404         = @notfound;
        access_log /var/log/access.foobar.com.log;
        error_log /var/log/error.foobar.com.log;

        location / {
                proxy_pass http://127.0.0.1:9030;
                proxy_pass_header Server;
                proxy_set_header Host $http_host;
                proxy_redirect off;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Scheme $scheme;
                proxy_connect_timeout 60;
                proxy_read_timeout 120;


        }
}

我需要做些什么来改变这项工作?

1 个答案:

答案 0 :(得分:2)

在这个配置中很难看到你想要的是什么。但可能

server {
       listen 443 spdy ssl;
       server_name foobar.com;
       ssl_certificate /etc/nginx/ssl/server.crt;
       ssl_certificate_key /etc/nginx/ssl/server.key;
        #error_page  404         = @notfound;
        access_log /var/log/access.foobar.com.log;
        error_log /var/log/error.foobar.com.log;
        location / {
                proxy_pass http://127.0.0.1:9030;
                proxy_pass_header Server;
                proxy_set_header Host $http_host;
                proxy_redirect off;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Scheme $scheme;
                proxy_connect_timeout 60;
                proxy_read_timeout 120;


        }
}


server {
        listen 80;
        server_name foobar.com;
        return 301 https://foobar.com$request_uri;

}

此配置将所有请求从http(80端口)重定向到同一服务器上的https(443端口)。并且在443端口请求是后端的代理。

相关问题