简体   繁体   中英

Trac & Apache Server: SSL & Virtual Hosts not working

I have configured an Ubuntu 16.04 Server with Apache and installed Trac 1.2.2 on it. I would like to access the Trac installation using SSL via https://subdomain.example.com

I have the following two .conf-files in /etc/apache2/sites-available/ right now:

ssl.conf:

<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/apache.crt
SSLCertificateKeyFile /etc/ssl/private/apache.key
DocumentRoot /var/www/html/

testinstallation.conf:

WSGIScriptAlias /trac/testinstallation /var/www/html/trac/testinstallation/cgi-bin/trac.wsgi

<Location /trac/testinstallation>
  AuthType Digest
  AuthName "testinstallation"
  AuthUserFile /var/lib/trac/testinstallation/.htdigest
  Require valid-user    
</Location>

When I open https://subdomain.example.com/trac/testinstallation , everything works as it should - but I would like to access my Trac-environment via https://subdomain.example.com . When I change the DocumentRoot in ssl.conf to /var/www/html/trac/testinstallation, I only get to see two folders, but not the Trac-environment (I don't know how to implement the WSGIScriptAlias to the ssl.conf). Can anybody help me with this problem?

Another question: Can I run multiple installations of Trac on one server using SSL? If yes, I would probably need another VirtualHost-file - but what should be in there?

The first parameter of WSGIScriptAlias is the URL-path. So to access your Trac installation over just the subdomain, you can modify the WSGIScriptAlias directive to

WSGIScriptAlias / /var/www/html/trac/testinstallation/cgi-bin/trac.wsgi

There is no need of mentioning the DocumentRoot . The WSGIScriptAlias directive takes care of it. If you want to run multiple Trac installations over multiple subdomains, repeat the same process that you have followed. ie,

  • Deploy project directory
  • Create Trac users
  • Create vhost and enable site

Else you can run multiple Trac installation as multiple subdirectories under the same subdomain by defining multiple WSGIScriptAlias directives in the same vhost file.

Example of vhost file for multiple Trac installations (test1 and test2) over single subdomain:

trac.conf

<VirtualHost *:443>
    SSLEngine On
    SSLCertificateFile /etc/ssl/certs/apache.crt
    SSLCertificateKeyFile /etc/ssl/private/apache.key
</VirtualHost>

WSGIScriptAlias /test1 /var/www/html/trac/test1/cgi-bin/trac.wsgi
<Location /login>
    AuthType Digest
    AuthName "test1"
    AuthUserFile /var/lib/trac/test1/.htdigest
    Require valid-user
</Location>

WSGIScriptAlias /test2 /var/www/html/trac/test2/cgi-bin/trac.wsgi
<Location /login>
    AuthType Digest
    AuthName "test2"
    AuthUserFile /var/lib/trac/test2/.htdigest
    Require valid-user
</Location>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM