Hosts file and nginx redirect from http to https on development server

674 views Asked by At

I am developing a website, and I just installed ssl on the production website (I have never done this before). When I load the development website the page redirects to https and breaks because https isn't installed on the development site.

The Nginx (production):

server{
        listen 80;
        server_name ezel.io;

        root /var/www/ezel.io/public;

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

        rewrite ^ https://$server_name$request_uri? permanent;
}

The Nginx (development):

server {
    listen          80;
    server_name     local.ezel.io;

    root            /home/ryan/Documents/www/ezel.io/public;
    index           index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;

        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

}

On my development machine, I also have the following in my hosts file:

127.0.0.1 local.ezel.io

What would be causing me to go from http://local.ezel.io to https://local.ezel.io?

example

1

There are 1 answers

0
Silex On

I think the problem is that you enabled https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security once and now your browser insists on trying HTTPS.

Try this: http://classically.me/blogs/how-clear-hsts-settings-major-browsers

Also, try pinging local.ezel.io to ensure it's really your localhost and not actually ezel.io.