我有一个使用 mod_proxy 在 Apache 后面提供烧瓶应用程序的 gunicorn。
Gunicorn 上http://localhost:8080/
。假设我的服务器已开启http://example.com/
有时,当我向我的服务器发布无效链接时(例如忘记尾随),假设http://example.com/with-no-trailing-slash
用户被重定向到无效链接,http://localhost:8080/with-no-trailing-slash
因为客户端计算机上没有服务器。
你知道它为什么会这样吗?以及如何解决这种行为?
要启动 gunicorn 我这样做: sudo gunicorn -b localhost:8080 app:app
<VirtualHost *:80>
ServerName example.com
ServerAlias example.com
DocumentRoot /opt/example
<Proxy *>
AuthType basic
AuthBasicAuthoritative Off
SetEnv proxy-chain-auth On
Order allow,deny
Allow from all
</Proxy>
# Let apache serve static files
ProxyPass /robots.txt !
ProxyPass /favicon.ico !
ProxyPass /static/ !
Alias /static/ /opt/example/app/static/
# Gunicorn handle the others
ProxyPass / http://localhost:8080/
# robots.txt et favicon.ico sont dans …
Run Code Online (Sandbox Code Playgroud)