【发布时间】:2023-03-18 14:45:01
【问题描述】:
我有一个使用 bjoern 作为 python 服务器的 Flask 应用程序。我有一个示例网址是这样的:
http://example.com/store/junihh
http://example.com/store/junihh/product-name
“junihh”和“product-name”是我需要传递给 python 的参数。
在阅读了有关 TCP/IP 调用的性能后,我尝试使用 unix 套接字。但现在我在浏览器上收到 502 错误。
这是我的 conf 的 sn-p:
upstream backend {
# server localhost:1234;
# server unix:/run/app_stores.sock weight=10 max_fails=3 fail_timeout=30s;
server unix:/run/app_stores.sock;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com www.example.com;
root /path/to/my/public;
location ~ ^/store/(.*)$ {
include /etc/nginx/conf.d/jh-proxy-pass.conf;
include /etc/nginx/conf.d/jh-custom-headers.conf;
proxy_pass http://backend/$1;
}
}
如何通过 Nginx proxy_pass 和 unix socket 将 url 参数传递给 Flask?
感谢您的帮助。
【问题讨论】:
标签: python nginx flask unix-socket