PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 21, 2022

[FIXED] How to make virtualhost section according to URL in same port?

 September 21, 2022     apache, mod-wsgi, virtualhost     No comments   

Issue

One apache httpd virtualhost section for mod_wsgi:

<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>

I want to add another wsgi app 'cf' for '/confirm' URL and ErrorLog, TransferLog for 'cf'.

Like this..

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"

How to make virtualhost section according to URL(/pf, /cf) in same port? Just make new virtualhost section?


Solution

You can only have the one access/error log per VirtualHost. You can't therefore have separate logs based on sub URL under the one site. Creating a separate VirtualHost will not help as that would have to have a different ServerName.

If you can give up the log file requirement, you can do:

<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>

It is better to set WSGIApplicationGroup to %{GLOBAL} when you only delegate one WSGI application to each daemon process group.



Answered By - Graham Dumpleton
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing