I have a domain that I can browse to via example.com:1234
. Now I do not want to always have to type the port at the very end, but rather have nginx redirect me to the static URL when browsing a subdomain eg. status.example.com
.
I have tried writing a redirect, but it didn't work at all.
server {
listen 80;
server_name status.example.com;
return 301 $scheme://www.example.com:1234;
}
Where's my error? Is it the server block? Am I missing something basic here?
Please try configuration as below,
server {
listen 80;
server_name status.example.com;
location / {
proxy_pass http://example.com:1234;
}
}
For reference use NGINX Reverse Proxy and Module ngx_http_proxy_module
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With