nginx 中的金字塔部署
pyramid deployment in nginx
我正在使用 nginx 在配置如下的服务器上为网站提供服务:
server {
listen 80;
server_name test.com
root /var/www/html;
error_log /var/log/test.log;
location / {
try_files $uri $uri/ index.html?$query_string;
}
location /rest/ {
proxy_pass http://localhost:6543;
}
}
/ 位置只有静态 html 和 js 文件,而 /rest/ 位置应该转到金字塔应用程序,但那部分不起作用。
如何将 /rest/ 位置传递给 http://localhost:6543 上的金字塔?
nginx访问日志:
127.0.0.1 - - [21/Sep/2018:15:20:39 +0800] "GET /rest HTTP/1.1" 502 182 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"
nginx 错误日志中没有任何内容
好的,请看下面我的观察和可能的解决方案
您已将 location
声明为 /rest/
(末尾有斜杠)
A. 尝试点击 /rest/
url。 (最后有斜杠)
当您点击 /rest
时,您的 access logs
出现了 502
错误。
A. 502
错误表示 服务器在充当网关或代理时,从上游服务器收到无效响应。
简而言之,查看 /rest
上的 运行 是什么代码,以及它是否按预期响应。
除此之外,考虑将 headers 添加到您的 /rest/
位置。
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
我正在使用 nginx 在配置如下的服务器上为网站提供服务:
server {
listen 80;
server_name test.com
root /var/www/html;
error_log /var/log/test.log;
location / {
try_files $uri $uri/ index.html?$query_string;
}
location /rest/ {
proxy_pass http://localhost:6543;
}
}
/ 位置只有静态 html 和 js 文件,而 /rest/ 位置应该转到金字塔应用程序,但那部分不起作用。
如何将 /rest/ 位置传递给 http://localhost:6543 上的金字塔?
nginx访问日志:
127.0.0.1 - - [21/Sep/2018:15:20:39 +0800] "GET /rest HTTP/1.1" 502 182 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"
nginx 错误日志中没有任何内容
好的,请看下面我的观察和可能的解决方案
您已将
location
声明为/rest/
(末尾有斜杠) A. 尝试点击/rest/
url。 (最后有斜杠)当您点击
/rest
时,您的access logs
出现了502
错误。 A.502
错误表示 服务器在充当网关或代理时,从上游服务器收到无效响应。
简而言之,查看/rest
上的 运行 是什么代码,以及它是否按预期响应。
除此之外,考虑将 headers 添加到您的 /rest/
位置。
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;