1

I have this nginx config:

worker_processes  1;
error_log  /home/paolino/error.log  notice;
events {worker_connections  1024;}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen              443 ssl;
        server_name         lambdasistemi.net;
        ssl_certificate     /home/paolino/lambdasistemi.net.crt;
        ssl_certificate_key /home/paolino/lambdasistemi.net.key;
        ssl_protocols       SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers         HIGH:!aNULL:!MD5;
        location /reactivegas/ {
            include   scgi_params;
            scgi_pass localhost:8000;
            }
        location /static {
            return 301 http://lambdasistemi.net$request_uri;
        }
    }
    server {
        listen 80;       
        location /reactivegas/ {
            return 301 https://lambdasistemi.net/reactivegas;
        }
        location /static {
            root /var/http;
        }
    }

upstream php {
    server unix:/var/run/php-fpm/php-fpm.sock;
    }
    include /etc/nginx/sites-enabled/*;
}

http://lambdasistemi.net/reactivegas works on firefox but on chrome I get a 404. https://lambdasistemi.net/reactivegas works on firefox but on chrome the links redirected to http are not loaded.

Is chrome not respecting the 301 or I've used a non compliant method ?

Thanks

paolino

1 Answers1

1

It works fine in chrome when you type /reactivegas/ - so the issue would simply be this:

    location /reactivegas/ {
        return 301 https://lambdasistemi.net/reactivegas;
    }

Edit that to this instead:

    location /reactivegas {
        return 301 https://lambdasistemi.net/reactivegas;
    }

and it should work.

Frederik
  • 3,359
  • 3
  • 32
  • 46
  • Thanks, there is still something broken in chrome, the link gets redirected to https but then the page doesn't load css or js links which should be redirected to http. I'm not sure if it's related to redirection, but firefox does it right and downloads css and js. – Paolo Veronelli Feb 14 '15 at 15:29
  • @PaoloVeronelli - The reason the site does not load CSS or JS is because they are being loaded from a HTTP connection and not HTTPS. Change your website code to load from HTTPS and it should work. – Frederik Feb 14 '15 at 15:30
  • Ok, it works with location /static {root /var/http;} in https. So I get that chrome cannot load http links from https pages and firefox can ? – Paolo Veronelli Feb 14 '15 at 15:35
  • @PaoloVeronelli - Chrome blocks the static content from loading if it is being served over HTTP when the site is loaded over HTTPS. It could look like Firefox doesn't do this. – Frederik Feb 14 '15 at 15:51
  • Interesting, you are referring to static content from the same site I suppose.How is it different from static content from other sites which I guess it's loaded ? – Paolo Veronelli Feb 14 '15 at 16:16
  • Also chrome is not loading https://lambdasistemi.net/static/favicon.ico while https://lambdasistemi.net/static/help.js is ok. With firefox both are working. – Paolo Veronelli Feb 14 '15 at 16:27