jwesonga
jwesonga

Reputation: 4383

Nginx redirects to default welcome page after https setup

I've configured SPDY on my Nginx instance and used http://spdycheck.org/ to confirm that its setup, but for some weird reason Nginx redirects the https to the default Nginx page, I've deleted the default symlink from sites-enabled, restarted the server but the problem persists. My site conf file has:

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;


        }
}

What do i need to change to make this work?

Upvotes: 0

Views: 3754

Answers (1)

mr_tron
mr_tron

Reputation: 838

It is difficult to see in this config what did you want. But probably

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;

}

This config redirect all request from http (80 port) to https (443 port) on same server. And on 443 port requests are proxy to backend.

Upvotes: 3

Related Questions