我試圖通過nginx來平衡一個web應用程序,它對我的web應用程序調用具有子路徑的服務都會正常工作。使用上游時NGINX沒有響應
例如它的工作原理
http://example.com/luna/
而不是
http://example.com/luna/sales
我的nginx.conf
user nobody;
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream lunaups {
server myhostserver1.com:8080;
server myhostserver2.com:8080;
}
server {
listen 80;
server_name example.com;
proxy_pass_header Server;
location =/{
rewrite^http://example.com/luna redirect;
}
location /luna {
rewrite ^$/luna/(.*)/^ /$1 redirect;
proxy_pass http://lunaups;
#add_header X-Upstream $upstream_addr;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
我的web應用程序調用與像/盧納/銷售更多的子路徑服務無法返回響應。我在這裏錯過了什麼?
它工作,如果我從上游移除我的主機服務器之一,但是當我在上游添加第二個主機時,它無法返回響應。
我的重寫規則是錯誤的還是我的配置整體錯誤?
'^ $/luna /(.*)/ ^'應該做什麼?它似乎有一個僞造的'$'和一個虛假的'^'。 –
嗨理查德,我是nginx新手,我自己構建了這個文件,只是在試驗和錯誤,請儘可能糾正我。 –
在向上遊發送之前是否應該從URI中刪除'/ luna'前綴? –