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, but it only pass
localhost:9292/json
to localhost/json
.
But What I want is
localhost:9292/json
to 'localhost'
localhost:9292/json/post
to 'localhost/post'
I think what I need to do is set root or do some rewrite, Anyone has some idea?
If you want to pass all connections from port 9092 to 80 you are listening the wrong port.
Change the port you are listening to 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 to avoid use root inside the location block, it's a common pitfall as explained in nginx documentation
Also you will need to configure another server to listen port 80.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.