Forum Discussion
redirect from http (port 80) to https (port 443) not working
Hi,
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;
> #server_name _;
> server_name marketplace.mydomain.com;
> ssl_protocols TLSv1.2;
> ssl_certificate /etc/ssl/certs/
> marketplace.mydomain.com/fullchain1.pem; ssl_certificate_key
> /etc/ssl/certs/marketplace.mydomain.com/privkey1.pem;
> if ($scheme = http) { return 301 https://$server_name$request_uri;
> }
> ssl_ciphers
> ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
> ssl_prefer_server_ciphers on;
> ssl_dhparam /etc/ssl/certs/marketplace.mydomain.com/dhparam.pem;
> client_max_body_size 100M;
> root /var/www/drupal/marketplace-v2/mpV2/web;
> access_log /var/log/nginx/access.log;
> error_log /var/log/nginx/error.log;
> # Load configuration files for the default server block.
> include /etc/nginx/default.d/*.conf;
> location = /favicon.ico {
> log_not_found off;
> access_log off;
> }
I will appreciate it if someone can pitch in for help. Please let me know
if you need any additional configurations and I look forward to hearing
from you. Thanks in Advance.
Best Regards,
Kaushal
- youssef1Cumulonimbus
Hello,
You have to listen on http service too:
server { listen 80; server_name _; return 301 https://$host$request_uri; }
https://linuxize.com/post/redirect-http-to-https-in-nginx/
regards
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com