The original post: /r/nginx by /u/These_Republic_4447 on 2024-11-30 06:43:02.

I want to redirect users from port 8000 to https. I have 3 domains. eohs.lrpnow.com, rcb.lrpnow.com, cimlearn.com ,all on port 8000. first two work correctly to redirect to https://cimlearn.com/

but when i type cimlearn.com:8000 it takes me to this: https://cimlearn.com:8000/ when it should redirect to https://cimlearn.com/ . what is wrong with my config? how do i fix this?

i have cleared my browser cache, tested incognito. but it is not working for that single domain cimlearn on 8000.

nginx config:

http {

Redirect port 8000 to HTTPS

server {

listen 8000 default_server;

server_name _;

Redirect all traffic to HTTPS on cimlearn.com

return 301 https://cimlearn.com$request\_uri;

\# Redirect all traffic to HTTPS on [cimlearn.com](http://cimlearn.com/) without including the port

return 301 https://cimlearn.com$uri$is\_args$args;

}

HTTPS Server Block for cimlearn.com

server {

listen 443 ssl;

server_name cimlearn.com;

ssl_certificate C:/nginx-1.26.0/certs/cimlearn.com-fullchain.pem;

ssl_certificate_key C:/nginx-1.26.0/certs/cimlearn.com-key.pem;

ssl_protocols TLSv1.2 TLSv1.3;

ssl_ciphers EECDH+AESGCM:EDH+AESGCM;

ssl_prefer_server_ciphers on;

Redirect www.cimlearn.com to cimlearn.com

server {

listen 443 ssl;

server_name www.cimlearn.com eohs.lrpnow.com rcb.lrpnow.com;

ssl_certificate C:/nginx-1.26.0/certs/cimlearn.com-fullchain.pem;

ssl_certificate_key C:/nginx-1.26.0/certs/cimlearn.com-key.pem;

ssl_protocols TLSv1.2 TLSv1.3;

ssl_ciphers EECDH+AESGCM:EDH+AESGCM;

ssl_prefer_server_ciphers on;

return 301 https://cimlearn.com$request\_uri;

}

}