2013-04-25 102 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.

相關問題