[GH-ISSUE #1466] Force SSL not working with non-standard port #1132

Closed
opened 2026-02-26 06:35:54 +03:00 by kerem · 7 comments
Owner

Originally created by @ysslang on GitHub (Oct 6, 2021).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1466

Checklist

  • Have you pulled and found the error with jc21/nginx-proxy-manager:latest docker image?
    • Yes
  • Are you sure you're not using someone else's docker image?
    • Yes
  • Have you searched for similar issues (both open and closed)?
    • Yes

Describe the bug

Similar to this question

Nginx Proxy Manager Version

2.9.9

To Reproduce
Steps to reproduce the behavior:

  1. While create docker container, bind container's 443 port to any port other than 443 on host, like 60443
  2. Create SSL certificates, create a proxy server and enable SSL and force-SSL
  3. Request http://server_name:60443. You'll get an 400 Error 'The plain HTTP request was sent to HTTPS port';

Expected behavior

Get a 302 redirect to https://server_name:60443

Screenshots

Operating System

Additional context

Solution is in this link too. Maybe 'error_page 497' is better than 'if() redirect'

Originally created by @ysslang on GitHub (Oct 6, 2021). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1466 <!-- Are you in the right place? - If you are looking for support on how to get your upstream server forwarding, please consider asking the community on Reddit. - If you are writing code changes to contribute and need to ask about the internals of the software, Gitter is the best place to ask. - If you think you found a bug with NPM (not Nginx, or your upstream server or MySql) then you are in the *right place.* --> **Checklist** - Have you pulled and found the error with `jc21/nginx-proxy-manager:latest` docker image? - Yes - Are you sure you're not using someone else's docker image? - Yes - Have you searched for similar issues (both open and closed)? - Yes **Describe the bug** <!-- A clear and concise description of what the bug is. --> Similar to [this question](https://serverfault.com/questions/338700/redirect-http-example-com12345-to-https-example-com12345-in-nginx) **Nginx Proxy Manager Version** <!-- What version of Nginx Proxy Manager is reported on the login page? --> 2.9.9 **To Reproduce** Steps to reproduce the behavior: 1. While create docker container, bind container's 443 port to any port other than 443 on host, like 60443 2. Create SSL certificates, create a proxy server and enable SSL and force-SSL 3. Request http://server_name:60443. You'll get an 400 Error 'The plain HTTP request was sent to HTTPS port'; **Expected behavior** <!-- A clear and concise description of what you expected to happen. --> Get a 302 redirect to https://server_name:60443 **Screenshots** <!-- If applicable, add screenshots to help explain your problem. --> **Operating System** <!-- Please specify if using a Rpi, Mac, orchestration tool or any other setups that might affect the reproduction of this error. --> **Additional context** <!-- Add any other context about the problem here, docker version, browser version, logs if applicable to the problem. Too much info is better than too little. --> Solution is in this [link](https://serverfault.com/questions/338700/redirect-http-example-com12345-to-https-example-com12345-in-nginx) too. Maybe 'error_page 497' is better than 'if() redirect'
kerem 2026-02-26 06:35:54 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@the1ts commented on GitHub (Oct 8, 2021):

Isn't one of the main points of NPM to simply and easily hide the mess of non-standard ports away from the client level?

What is the reason for the non-standard SSL port? ISP port blocking, permission issue for low numbered ports?

Although mixing http and https on a single port is possible, its never encouraged for security reasons and never been in any specification I've seen. Other specs allow the upgrade to SSL, i.e. email. But that is signed off at a specification level and only requires user intervention once at setup, not everytime a URL is typed.

<!-- gh-comment-id:938657637 --> @the1ts commented on GitHub (Oct 8, 2021): Isn't one of the main points of NPM to simply and easily hide the mess of non-standard ports away from the client level? What is the reason for the non-standard SSL port? ISP port blocking, permission issue for low numbered ports? Although mixing http and https on a single port is possible, its never encouraged for security reasons and never been in any specification I've seen. Other specs allow the upgrade to SSL, i.e. email. But that is signed off at a specification level and only requires user intervention once at setup, not everytime a URL is typed.
Author
Owner

@ysslang commented on GitHub (Oct 8, 2021):

What is the reason for the non-standard SSL port? ISP port blocking, permission issue for low numbered ports?

Yes! You nailed it! My ISP, or Chinese ISPs blocked common service ports, like 443, 80, etc. So we have to deal with non-stantard ports. So please do me a favor.

<!-- gh-comment-id:938698129 --> @ysslang commented on GitHub (Oct 8, 2021): > What is the reason for the non-standard SSL port? ISP port blocking, permission issue for low numbered ports? > Yes! You nailed it! My ISP, or Chinese ISPs blocked common service ports, like 443, 80, etc. So we have to deal with non-stantard ports. So please do me a favor.
Author
Owner

@Danielv123 commented on GitHub (Oct 11, 2021):

This sounds like it is best solved by hosting nginx in the cloud and routing traffic back to your home network using an overlay network service like tailscale or zerotier. This way you won't have to deal with your ISP gatekeeping ports.

Normal http -> https redirection works by you entering http://my.domain:80 and being redirected to https://my.domain:443, which wouldn't work if you enter the wrong port.

<!-- gh-comment-id:939916925 --> @Danielv123 commented on GitHub (Oct 11, 2021): This sounds like it is best solved by hosting nginx in the cloud and routing traffic back to your home network using an overlay network service like tailscale or zerotier. This way you won't have to deal with your ISP gatekeeping ports. Normal http -> https redirection works by you entering http://my.domain:80 and being redirected to https://my.domain:443, which wouldn't work if you enter the wrong port.
Author
Owner

@zierbeek commented on GitHub (Mar 8, 2022):

does force ssl even work with the standard ports? At my instance, with subdomains, that isn't working

<!-- gh-comment-id:1061507687 --> @zierbeek commented on GitHub (Mar 8, 2022): does force ssl even work with the standard ports? At my instance, with subdomains, that isn't working
Author
Owner

@yqchilde commented on GitHub (Jun 21, 2022):

@ysslang Have you solved it? I have encountered the same situation.

<!-- gh-comment-id:1161012435 --> @yqchilde commented on GitHub (Jun 21, 2022): @ysslang Have you solved it? I have encountered the same situation.
Author
Owner

@yqchilde commented on GitHub (Jun 22, 2022):

@ysslang Have you solved it? I have encountered the same situation.

This is how I finally solved it!
error_page 497 301 =301 https://your_domain:your_port$request_uri;

<!-- gh-comment-id:1162885699 --> @yqchilde commented on GitHub (Jun 22, 2022): > @ysslang Have you solved it? I have encountered the same situation. This is how I finally solved it! error_page 497 301 =301 https://your_domain:your_port$request_uri;
Author
Owner

@RobertusIT commented on GitHub (Aug 21, 2023):

@ysslang Have you solved it? I have encountered the same situation.

This is how I finally solved it! error_page 497 301 =301 https://your_domain:your_port$request_uri;

please can you explain better?

My isp block a port range, so i open 443 to 32763
80 to 32764

How can I setup in proxy manager?

<!-- gh-comment-id:1686371652 --> @RobertusIT commented on GitHub (Aug 21, 2023): > > @ysslang Have you solved it? I have encountered the same situation. > > This is how I finally solved it! error_page 497 301 =301 https://your_domain:your_port$request_uri; please can you explain better? My isp block a port range, so i open 443 to 32763 80 to 32764 How can I setup in proxy manager?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-proxy-manager-NginxProxyManager#1132
No description provided.