gpt4 book ai didi

python - Bokeh 服务器 + 使用 Nginx 进行反向代理给出 404

转载 作者:行者123 更新时间:2023-11-28 22:35:36 25 4
gpt4 key购买 nike

我正在尝试设置 Bokeh 服务器并使用 Nginx 对其进行反向代理。

我的 p-website.conf 现在看起来像:

server {
listen 80;
server_name website.com;
client_max_body_size 25M;
access_log /var/www/logs/p-website.access.nginx.log;
error_log /var/www/logs/p-website.error.nginx.log error;
root /var/www/pydocs/website/production/src;

include global/restrictions.conf;


location /plot/ {
proxy_pass http://website.com:5100;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port;
proxy_buffering off;
}

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# enable this if and only if you use HTTPS, this helps Rack
# set the proper protocol for doing redirects:
# proxy_set_header X-Forwarded-Proto https;

proxy_set_header Host $http_host;
proxy_redirect off;
proxy_connect_timeout 10;
proxy_read_timeout 60s;

proxy_pass http://production_website_gunicorn;
}
}

在我运行 Bokeh 服务器的服务器上:

bokeh serve bokehserver.py --port 5100 --host website.com:80

但是当我访问 website.com/plot/时,我从 Bokeh 收到了 404,服务器终端给我:WARNING:tornado.access:404 GET/("here was ip address") 3.04ms

不明白为什么总是404,还是跟Nginx有关?

谢谢!

更新 30/06

好的,我想我更进一步了,希望朝着好的方向发展。我的 p-website.conf 现在看起来像:

server {
listen 80 default_server;
server_name website.com;
client_max_body_size 25M;
access_log /var/www/logs/p-website.access.nginx.log;
error_log /var/www/logs/p-website.error.nginx.log error;
root /var/www/pydocs/magnify/production/src;

include global/restrictions.conf;


location / {
allow 127.0.0.1:5100
proxy_pass http://127.0.0.1:5100;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port;
proxy_buffering off;
}

}

我现在运行服务器:

bokeh serve bokehserver.py --port 5100 --host 127.0.0.1:80

现在我不再收到 404,而是在访问 website.com:5100/bokehserver/时收到“403:禁止访问”。在 bokehserver 终端中显示此消息:

INFO:bokeh.server.tornado:Rejected connection from host 'website.com:5100' because it is not in the --host whitelist
WARNING:tornado.access:403 GET /bokehserver/ (213.152.161.35) 0.78ms

我试图通过在 p-website.conf 中添加 allow 127.0.0.1:5100 来解决白名单问题,但没有成功。

最佳答案

我想通了,显然你需要在 Bokeh 命令中添加具有相同位置的 --prefix=:

bokeh serve bokehserver.py --port 5100 --prefix=/plot/ --host website.com:80

p-website.conf 中的位置 block 将如下所示:

location /plot/ {
proxy_pass http://127.0.0.1:5100;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port;
proxy_buffering off;
}

关于python - Bokeh 服务器 + 使用 Nginx 进行反向代理给出 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38081389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com