Welcome! Log In Create A New Profile

Advanced

RE: redirect from http (port 80) to https (port 443) not working.

Reinis Rozitis
June 15, 2020 02:22PM
> I am running nginx version: nginx/1.16.1 on CentOS Linux release 7.8.2003 (Core). When I hit https://marketplace.mydomain.com it works perfectly fine whereas when I hit http://marketplace.mydomain.com
> (port 80) does not get redirected to https://marketplace.mydomain.com (port 443). I have the below nginx.conf.
>
> server {
> listen 443 ssl default_server;
> #listen 80 default_server;


Either reenable listen 80 default_server; or add another server block:

server {
listen 80 default_server;
server_name marketplace.mydomain.com;
return 301 return 301 https://$server_name$request_uri;
}

Because if you don't listen on port 80 the only way $scheme will be 'http' (and the if condition true) if the client opens http://yoursite:443 which won't normally happen.

rr

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

redirect from http (port 80) to https (port 443) not working.

kaushalshriyan June 15, 2020 01:02PM

RE: redirect from http (port 80) to https (port 443) not working.

Reinis Rozitis June 15, 2020 02:22PM

RE: redirect from http (port 80) to https (port 443) not working.

Reinis Rozitis June 15, 2020 02:26PM

Re: redirect from http (port 80) to https (port 443) not working.

kaushalshriyan June 16, 2020 08:18AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 80
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready