我正在使用Pyramid,pserve(通过Supervisord运行)和nginx。如果我希望我的应用程序在/
以外的位置可用(例如/xml/
),我应该在应用程序中为路由添加前缀,还是有办法在nginx中设置所有内容?这就是我现在的表现:
nginx的:
location /xml {
proxy_pass http://127.0.0.1:6544;
}
金字塔:
config.add_static_view('/xml/static', 'static', cache_max_age=3600)
config.add_route('system_admin', '/xml/admin')
最好不要单独在nginx中执行此操作,因为您的webapp可能会生成自己的URL,其中一些可能包含绝对路径。因此,如果它认为它是在/
上托管的,它将生成错误的URL,并且nginx无法知道。
如果你真的想这样做,你可以尝试这样的重写规则:
location /xml {
rewrite /xml(.*) $1 break;
proxy_pass http://127.0.0.1:6544;
}