Bouncing to Default Server Block

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Bouncing to Default Server Block

Bee.Lists
I have a test server up with 3 domains.  

First domain redirects port 80 to ssl 443.  
Second domain is just port 80.
Third domain is just port 80.  

Second domain isn’t showing up, pointing to first domain.  Third domain is working.  Why would this happen?

nginx.conf:

# user                          nginx;
worker_processes        auto;

error_log  /var/log/nginx/error.log;
pid        /run/nginx.pid;
events {     worker_connections  1024;        }

http {
    include /etc/nginx/mime.types;
    keepalive_timeout 65s;
    gzip on;
    index index.html;

    passenger_app_env                       development;
    passenger_friendly_error_pages          on;
    include /etc/nginx/conf.d/*.conf;

    server {
        listen                                  80;
        server_name                             domain1.ca www.domain1.ca;
        return 301                              https://$server_name$request_uri;
    }

    server {
        listen 443 default_server;
        server_name                             domain1.ca www.domain1.ca;
        access_log                              /var/log/nginx/access_domain1.log;
        error_log                               /var/log/nginx/error_domain1.log  warn;
        error_page  404                         /404.html;
        client_max_body_size                    3M;              
        root                                    /var/www/domain1/public;
        passenger_enabled                       on;
        passenger_base_uri                      /;

        location / {
                autoindex                       off;
        }
    location = /img/favicon.ico { access_log off;}

        ssl                                     on;
        ssl_certificate                         /etc/nginx/ssl/domain1_ca.crt;        
        ssl_certificate_key                     /etc/nginx/ssl/domain1.key;          
        ssl_protocols                           TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ALL:!aNULL:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    }

    server {
            listen                              80;
            server_name                         domain2 www.domain2;
            access_log                          /var/log/nginx/access_vp.log;
            error_log                           /var/log/nginx/error_vp.log  debug;
            error_page  404                     /404.html;
            root                                /var/www/domain2/public;
            passenger_enabled                   on;
            passenger_base_uri                  /;

            location / {
                autoindex                       off;
#                index                           /;
            }
            location = /favicon.ico { access_log off; log_not_found off; }
            location = /robots.txt { access_log off; log_not_found off; }
            sendfile                            off;
        }

   server {
            listen                              80;
            server_name                         domain3.com www.domain3.com;
            access_log                          /var/log/nginx/access_domain3.log;
            error_log                           /var/log/nginx/error_domain3.log error;
            error_page 404                      /404.html;
            root                                /var/www/domain3/public;
            passenger_enabled                   on;
            passenger_base_uri                  /;

            location / {
                autoindex                       off;
                index                           /;
                }

            location = /img/favicon.ico { access_log off; log_not_found off; }
            location = /robots.txt { access_log off; log_not_found off; }
            sendfile                            off;
        }
}








Cheers, Bee




_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

RE: Bouncing to Default Server Block

Reinis Rozitis
> First domain redirects port 80 to ssl 443.
> Second domain is just port 80.
> Third domain is just port 80.
>
> Second domain isn’t showing up, pointing to first domain.  Third domain is
> working.  Why would this happen?

If you are testing just with a browser make sure you've cleaned the cache (or disable it, or use some other tools which don't have cache (like wget for example)).

If by chance you opened the http://domain2 before it was added to the nginx configuration (or before nginx got reloaded) your browser cached the domain1 301 redirect and isn't actually doing a real request to the webserver anymore

rr

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Bouncing to Default Server Block

Bee.Lists
I often clear the cache and restart nginx.


> On Sep 28, 2018, at 11:19 AM, Reinis Rozitis <[hidden email]> wrote:
>
> If you are testing just with a browser make sure you've cleaned the cache (or disable it, or use some other tools which don't have cache (like wget for example)).
>
> If by chance you opened the http://domain2 before it was added to the nginx configuration (or before nginx got reloaded) your browser cached the domain1 301 redirect and isn't actually doing a real request to the webserver anymore
>
> rr



Cheers, Bee




_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Bouncing to Default Server Block

Bee.Lists
It’s fixed.  Thank you


> On Sep 28, 2018, at 11:48 AM, Bee.Lists <[hidden email]> wrote:
>
> I often clear the cache and restart nginx.



Cheers, Bee




_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx