简体   繁体   中英

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

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 ?

例

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM