nginx reverse proxy to backend running on localhost -
edit: turns out setup below works. previously, getting redirections port 36000 due configuration settings on backend application causing it.
i not entirely sure, believe might wanting set reverse proxy using nginx.
i have application running on server @ port 36000. default, port 36000 not publicly accessible , intention nginx listen public url, direct request url application running on port 36000. during entire process, user should not know his/her request being sent application running on server's port 36000.
to put in more concrete terms, assume url http://domain.somehost.com/
upon visiting http://domain.somehost.com/ , nginx should pick request , redirect application running on server on port 36000, application processing, , passes response back. port 36000 not publicly accessible , should not appear part of url.
i've tried setup looks like:
server { listen 80; server_name domain.somehost.com location / { proxy_pass http://127.0.0.1:36000; proxy_set_header host $host; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; } }
and including inside main nginx.conf
however, requires me make port 36000 publicly accessible, , i'm trying avoid that. port 36000 shows part of forwarded url in web browser.
is there way can same thing, without making port 36000 accessible?
thank you.
edit: config below working nginx config, hostname , port changed.
you need may able set server listening on port 36000 upstream
server (see http://nginx.org/en/docs/http/ngx_http_upstream_module.html).
server { listen 80; server_name domain.somehost.com; location / { proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $host; proxy_set_header x-nginx-proxy true; proxy_pass http://localhost:36000/; proxy_redirect http://localhost:36000/ https://$server_name/; } }
Comments
Post a Comment