docker - How to rewrite or proxy url in nginx? -
i new in nginx. want rewrite
feature-1234.mydomain.com/xyz?foo=bar
to
docker-feature-1234:9000/xyz?foo=bar
with request parameters.
i use official nginx docker image. how should nginx.conf file?
edit: 'feature-1234' variable so:
feature-5678.mydomain.com
should serve
docker-feature-5678:9000
by combining answers, found solution.
https://serverfault.com/questions/388552/nginx-sub-domain-proxy-pass
nginx: [emerg] "server" directive not allowed here
nginx.conf:
events { } http { server { listen 80; server_name ~(.*).test.go; location / { if ($host ~* ^([a-za-z0-9-]+)\.test\.go$) { set $proxyhost docker-$1:9000; } resolver 127.0.0.11 ipv6=off; proxy_pass http://$proxyhost; proxy_http_version 1.1; proxy_set_header upgrade $http_upgrade; proxy_set_header x-forwarded-for $remote_addr; proxy_set_header x-real-ip $remote_addr; proxy_set_header host $host; } } }
thanks
Comments
Post a Comment