How to redirect localhost:9292/json to localhost:80/ using Nginx reverse proxy? -
server { listen 80; server_name localhost; location / { index index.html; root /users/lin/codes/js/emberjs/yeoman-ember/dist; } location ~* ^/json { root proxy_pass http://localhost:9292; } }
the configure kinda works, pass
localhost:9292/json
localhost/json
.
but want
localhost:9292/json
'localhost'
localhost:9292/json/post
'localhost/post'
i think need set root or rewrite, has idea?
if want pass connections port 9092 80 listening wrong port.
change port listening 9092:
server { listen 9092; server_name localhost; root /users/lin/codes/js/emberjs/yeoman-ember/dist; location / { index index.html; } location ~* ^/json { proxy_pass http://localhost:80; proxy_set_header x-real-ip $remote_addr; } }
try avoid use root inside location block, it's common pitfall explained in nginx documentation
also need configure server listen port 80.