Ale*_*ist 7 mod-proxy gunicorn apache-2.4
我有一个使用 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 /path/to/django/project/static/
Alias /robots.txt /path/to/django/project/static/robots.txt
Alias /favicon.ico /path/to/django/project/static/favicon.ico
Alias /favicon.ico /path/to/django/project/static/favicon.ico
<Directory /path/to/django/project>
Order deny,allow
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
如果您需要其他配置文件,请告诉我!
您缺少反向映射,它对 Apache 重定向 URL 重写非常有用。在 99% 的情况下,正向和反向映射是相同的。
添加这个:
ProxyPassReverse / http://localhost:8080/
Run Code Online (Sandbox Code Playgroud)
并重新加载Apache。
归档时间: |
|
查看次数: |
11313 次 |
最近记录: |