如何根据同一端口中的 URL 制作虚拟主机部分?

How to make virtualhost section according to URL in same port?

mod_wsgi 的一个 apache httpd 虚拟主机部分:

<VirtualHost *:443>
    WSGIScriptAlias /pf /home/services/pf/pf.wsgi 
    WSGIDaemonProcess pf user=wsgi user=operator processes=10 threads=5 display-name=%{GROUP}

    WSGIApplicationGroup %{RESOURCE}
    WSGIProcessGroup pf

    ErrorLog "/home/log/pf-error.log"
    TransferLog "/home/log/pf-access.log"

   <Directory /home/services/pf>
      Require all granted
    </Directory>
</VirtualHost>

我想为“/confirm”添加另一个 wsgi 应用程序 'cf' URL ErrorLogTransferLog 'cf'。

像这样..

WSGIScriptAlias /cf /home/services/cf/cf.wsgi 
WSGIDaemonProcess cf user=wsgi user=operator processes=10 threads=5 display-name=%{GROUP}

WSGIApplicationGroup %{RESOURCE}
WSGIProcessGroup cf

ErrorLog "/home/log/cf-error.log"
TransferLog "/home/log/cf-access.log"

如何在同一端口根据URL(/pf, /cf) 制作虚拟主机部分? 只是制作新的虚拟主机部分?

每个 VirtualHost 只能有一个 access/error 日志。因此,您不能在一个站点下拥有基于子 URL 的单独日志。创建一个单独的 VirtualHost 将无济于事,因为那必须有一个不同的 ServerName.

如果你可以放弃日志文件要求,你可以这样做:

<VirtualHost *:443>
    WSGIScriptAlias /pf /home/services/pf/pf.wsgi 
    WSGIDaemonProcess pf user=wsgi user=operator processes=10 threads=5 display-name=%{GROUP}

    WSGIScriptAlias /cf /home/services/cf/cf.wsgi 
    WSGIDaemonProcess cf user=wsgi user=operator processes=10 threads=5 display-name=%{GROUP}

    WSGIApplicationGroup %{GLOBAL}

   <Directory /home/services/pf>
      WSGIProcessGroup pf
      Require all granted
    </Directory>

   <Directory /home/services/cf>
      WSGIProcessGroup cf
      Require all granted
    </Directory>

    ErrorLog "/home/log/error.log"
    TransferLog "/home/log/access.log"
</VirtualHost>

当您只将一个 WSGI 应用程序委托给每个守护进程组时,最好将 WSGIApplicationGroup 设置为 %{GLOBAL}