我的目标是编写Jasmine(一个JavaScript BDDtesting框架)testing,这个testing是由一个单独的团队构build的后端API。
我有一个运行在端口9000上的Jasmine服务器。该代码发出一个以/ web /开头的相对path的AJAX请求。 我希望这些请求被引导到后端。
到目前为止,我已经得到了一个逆向代理,像这样:
upstream backend { server api-dev.example.com; } server { ... location / { proxy_pass http://localhost:9000; ... } location /web/ { proxy_pass https://backend/web/; ... } }
stream量到“/”工作正常,但AJAX请求(例如,到
http://localhost:50000/web/internal?action=network-statistics
)502。 我相信这是正确的端点,但有一个SSL错误。 Nginx的错误日志似乎证实了我的怀疑:
2013/12/13 16:55:28 [error] 1885#0: *257 SSL_do_handshake() failed (SSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol) while SSL handshaking to upstream, client: 127.0.0.1, server: localhost, request: "GET /web/internal/stats?action=network-statistics&request=null HTTP/1.1", upstream: "https://50.18.192.173:80/web/internal/stats?action=network-statistics", host: "localhost:50000", referrer: "http://localhost:50000/"
但是,如果我将上游块更改为:
upstream backend { server api-dev.example.com:443; }
…然后我得到404s。 Coulda发誓我已经看到类似的configuration在Server Fault的其他地方工作。 例如, 这是一个非常类似的问题。 我错过了什么? 有什么可能会出错? 对不起,如果这是模糊的,我很高兴添加更多的细节。
尝试删除/网页/。 我想你404,因为它试图访问/networking/networking不存在。 你应该能够从Nginx日志中find更多的提示。
upstream backend { server api-dev.example.com:443; } server { ... location / { proxy_pass http://localhost:9000; ... } location /web/ { proxy_pass https://backend; ... } }