2013-04-25 107 views
0
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; 

     } 
    } 

的配置有点工作,但它只能通过如何使用Nginx反向代理将localhost:9292/json重定向到localhost:80 /?

localhost:9292/jsonlocalhost/json

但我要的是

localhost:9292/json为“localhost”的

localhost:9292/json/post为“本地主机/后”

我想我需要做的是设置root或做一些改写,任何人有一些想法?

回答

0

如果您想要将所有连接从端口9092传递到80,您正在监听错误的端口。

更改您正在收听的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; 
    } 
} 

尽量避免位置块内使用root,这是因为在nginx documentation

解释常见的错误,你还需要配置其他服务器听港80.

相关问题