NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
22.22k stars 2.56k forks source link

Redirection Host missing colon when redirection created #2276

Closed MatthewReed303 closed 2 years ago

MatthewReed303 commented 2 years ago

Checklist

Describe the bug

When creating a simple redirection host to forward https://domainA.com to https://domainB.com ( without SSL elected in NPM ) the redirection misses the colon in the https://

Example the redirection is https//domainB.com and should be https://domainB.com

I have tried scheme in Auto and http and https with same result.

On the Forward Domain I have tried just domainB.com and adding https:// in front myself https://domainB.com and I get the same result in the redirection

Edit: It seems NPM is not removing the the old rules when deleted. I realized it's trying to use an old deleted misconfigured rule. Even if I delete a rule the redirection rule deleted still works, it still works after I restart the container. The only way to get the new rule to work is change to docker dev branch and the go back to the latest and the new rule then works.

Nginx Proxy Manager Version v2.9.18

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior I expect redirection to contain the colon :

Screenshots

Operating System Ubuntu 22.04

Additional context

the1ts commented 2 years ago

@MatthewReed303 I'm confused how and where you are putting https://. The UI doesn't need or want the scheme (http:// or https://) in the "domain names" section or the "forward domain" section. Its the scheme drop down that handles the redirect schemes http => http, https => https or auto (both). You cannot do http => https, you would have to handle that on the redirected domain doing force SSL. I think the colon is being removed by some input cleansing that perhaps should error or remove the whole thing instead of turning http://test.com into http//test.com and saving. As to the rule being used after the redirect is removed, its almost certainly browser caching the 302 redirect, always a problem with redirects.

the1ts commented 2 years ago

Also of note, I'm not sure https:// redirect is available if the SSL section is ignored. If nginx isn't able to create a https connection (which requires a cert) then it can't inject the redirect into that SSL tunnel.

MatthewReed303 commented 2 years ago

Hi @the1ts I was using the scheme drop down to select https etc I did have the http:// => https:// working without SSL enabled, but doesn't seem to work now. How would I do a plain https:// to https:// redirect where both domains already have a SSL cert from my domain provider?

I think my other issue is I have Traefik running on port 80/443 which handles all my docker certs and then I have some rules to catch all port 80/443 and then pass to Nginx. This is working and Nginx gets the requests but Traefik inserts default cert before it reaches Nginx and I don't think Nginx can over ride the default cert, it show as insecure and shows the TRAEFIK DEFAULT CERT and I also get the Your connection is not secure ( Traefik cert issue ) if I continue, I get 400 response from Nginx

400 Bad Request The plain HTTP request was sent to HTTPS port

I have been using chrome in the incognito mode to try prevent cache issues, but I may have made a mistake and not opened a new window etc

Basically my end goal is I have a few redirections

1: DomainA to DomainB ( both of these domains already have SSL certs ) 2: DomainC to DomainD ( DomainC has no cert and will get cert via NPM and DomainD already has a cert ) 3: DomainE to IP/port ( Normal reverse proxy to back end service NPM provides cert for DomainE )

the1ts commented 2 years ago

I'm getting confused keeping up with both what you have and what you want to do, but: I simply don't understand why you have both traefik and nginx doing the same job, getting SSL certs either from letsencrypt or uploaded from a more manual SSL cert supplier and reverse proxying traffic for you. I'm not sure you can have both doing this especially on https since traefik cannot setup an HTTPS connection without the cert for that domain if it cannot setup the tunnel, it cannot forward it to NPM. I think the only way this can work is to have one proxy and terminate all traffic there, doesn't really matter if its traefik or NPM they are both capable of doing your simple requirements. The whole reason you are seeing the default cert from traefik is that the cert for that domain isn't on traefik so a good SSL tunnel cannot be setup and the web browser is complaining. One proxy needs to handle all domains and certs.

MatthewReed303 commented 2 years ago

Hi @the1ts Thanks for the info and sorry for the confusion. Basically I was running 2 servers my old one which was just NPM and I was using WireGuard VPN and NPM was just reverse proxy to the backend. Now I have setup a new server and using Netmaker ( a wrapper for wireguard ) The problem is Netmaker uses Traefik for all it's configs and SSL. I still want to use NPM for my VPN reverse proxies as I can easily set them up and change them etc via UI Interface... no need to ssh into server to make proxy changes which I would have to do with Traefik.

I have now got them both going and working together, I'm using catch all rules with Traefik and passing onto Nginx. I'm also using TLS pass through. Here are the rules below if anyone needs to achieve something similar in the future.

labels:

Reverse Proxy SSL for Nginx Dashboard

  - "traefik.enable=true"
  - "traefik.http.routers.nginx.rule=Host(`nginx.xxx.xxxx.com`)"
  - "traefik.http.routers.nginx.entrypoints=websecure"
  - "traefik.http.routers.nginx.tls=true"
  - "traefik.http.routers.nginx.tls.certresolver=http"
  - "traefik.http.routers.nginx.service=nginxService"
  - "traefik.http.services.nginxService.loadBalancer.server.port=81"
  #Catch all traffic on Port 80 for Nginx Proxy Manager
  - "traefik.http.routers.nginx1.rule=HostRegexp(`{domain:.+}`)"
  - "traefik.http.routers.nginx1.priority=1"
  - "traefik.http.routers.nginx1.entrypoints=web"
  - "traefik.http.routers.nginx1.service=nginxService1"
  - "traefik.http.services.nginxService1.loadBalancer.server.port=80"
  #Catch all traffic on Port 443 for Nginx Proxy Manager
  - "traefik.tcp.routers.nginx2.rule=HostSNIRegexp(`{domain:.+}`)"
  - "traefik.tcp.routers.nginx2.tls.passthrough=true"
  #- "traefik.tcp.routers.nginx2.priority=2"
  - "traefik.tcp.routers.nginx2.entrypoints=websecure"
  - "traefik.tcp.routers.nginx2.service=nginxService2"
  - "traefik.tcp.services.nginxService2.loadBalancer.server.port=443"
  #Proxy Network
  - "traefik.docker.network=proxy"