Hello @all,
I have the following challenge. I have a portrange arriving on my nginx server.
Each port should be sent to a remote host on the same port.
The variable $server_port unfortunately does not work.
To be more specific if I specify a port in the nginx-config e.g.: "proxy_pass http://sonartype-nexus:9001/;"
everything works well.
If i use the Variable: "proxy_pass http://sonartype-nexus:$server_port/" it does not work.
Following my config:
server {
listen 9000-9100 ssl;
server_name example.com;
# Allow upload of large files,
# needed if Nexus is going to host large size artifacts
client_max_body_size 20G;
# Add the certificate and key generated earlier
ssl_certificate /etc/nginx/letsenc_cert.pem;
ssl_certificate_key /etc/nginx/letsenc_key.pem;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_pass http://sonartype-nexus:$server_port/;
}
}
Thanks Frank