我有一个在 prod 中运行的 WSGI 应用程序,并且我想在同一台服务器上运行一个 staging 应用程序,因此我在不同的端口配置了两个虚拟主机,prod 端口为 80,stag 端口为 9090,但每次我请求端口 9090 时,它都会使用 prod 应用程序,我不知道为什么。这是我的配置:
产品.conf:
LoadModule wsgi_module modules/mod_wsgi.so
NameVirtualHost *:80
ServerName dashboard
<VirtualHost *:80>
ServerName dashboard
WSGIDaemonProcess dashboard display-name=%{GROUP}
WSGIProcessGroup dashboard
WSGIScriptAlias / /srv/dashboard/wsgi.py process-group=dashboard application-group=dashboard
WSGIPassAuthorization on
Alias /static/ /srv/dashboard/static/
Alias /favicon.ico /srv/dashboard/static/favicon.ico
DocumentRoot "/srv/dashboard"
<Directory /srv/dashboard>
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride None
Require all granted
</Directory>
<Directory /srv/dashboard/static>
Options +Indexes +FollowSymLinks +MultiViews
Require all granted
</Directory>
ErrorLog "/var/log/httpd/dashboard-error.log"
CustomLog "/var/log/httpd/dashboard-access.log" common
</VirtualHost>
stag.conf:
LoadModule wsgi_module modules/mod_wsgi.so
Listen 9090
NameVirtualHost *:9090
ServerName dashboard-stagging
<VirtualHost *:9090>
ServerName dashboard-stagging
WSGIDaemonProcess dashboard-stagging display-name=%{GROUP}
WSGIProcessGroup dashboard-stagging
WSGIScriptAlias / /srv/dashboard-stagging/wsgi.py process-group=dashboard-stagging application-group=pnpdash$
WSGIPassAuthorization on
Alias /static/ /srv/dashboard-stagging/static/
Alias /favicon.ico /srv/dashboard-stagging/static/favicon.ico
DocumentRoot "/srv/dashboard-stagging"
<Directory /srv/dashboard-stagging>
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride None
Require all granted
</Directory>
<Directory /srv/dashboard-stagging/static>
Options +Indexes +FollowSymLinks +MultiViews
Require all granted
</Directory>
ErrorLog "/var/log/httpd/dashboard-stag-error.log"
CustomLog "/var/log/httpd/dashboard-stag-access.log" common
</VirtualHost>
当我请求时,我的 /var/log/httpd/dashboard-stag-access.log 保持为空http://dashboard.mycompany.com:9090并且它在端口 80 中使用该应用程序。
有什么指导吗?
答案1
检查 wsgi 调用的应用程序的 cookie 名称(prod 和 stag),它们不能冲突。示例:我有 2 个分别使用 flask 和 wsgi 的应用程序,它们使用相同的程序但参数不同。我必须为 config["SESSION_COOKIE_NAME"] 分配不同的值以避免冲突。