I am trying to rewrite requests to http://www.example.com:88 to https://www.example.com:4430
At the moment, I am stuck with nonstandard ports. Here is my configuration:
upstream pool {
server 127.0.0.1:5001;
server 127.0.0.1:5002;
}
server {
listen 88;
listen 4430 default ssl;
if ($ssl_protocol = "") {
rewrite ^ https://$server_name:4430/$uri permanent;
# this also fails with https://www.example.com/:4430
#rewrite ^/(.*)$ https://$host:4430/$1 permanent;
#rewrite ^ https://www.example.com:4430/ permanent;
}
location / {
proxy_pass http://pool;
proxy_set_header Host $host;
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
This results in http://www.example.com:88/path being rewritten to https://www.example.com/path:4430
What's the syntax to get the port after the domain name?