Score:0

Two applications on apache2 subdomain.example.com and example.com

ng flag

I would like to get working apache2 configuration with http://openproject.example.com and https://example.com (wordpress blog).

My configuration:

/etc/apache2/sites-enabled/wordpress.conf

<VirtualHost *:80>
        ServerAdmin admin@HOSTNAME_HERE.com
        DocumentRoot /var/www/HOSTNAME_HERE/wordpress/
        Redirect / https://HOSTNAME_HERE.com/
        <Directory /var/www/HOSTNAME_HERE/wordpress/>
                Options +FollowSymLinks
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

/etc/apache2/conf-enabled/wordpress.conf

Alias /wordpress /var/www/HOSTNAME_HERE/wordpress
<Directory /var/www/HOSTNAME_HERE/wordpress>
    Options FollowSymLinks
    DirectoryIndex index.php
    <IfModule mod_php.c>
        <IfModule mod_mime.c>
            AddType application/x-httpd-php .php
        </IfModule>
        <FilesMatch ".+\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>
    </IfModule>
</Directory>
<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authz_core.c>
        <IfModule mod_authn_file.c>
            AuthType Basic
        </IfModule>
        Require valid-user
    </IfModule>
</Directory>
<Directory /usr/share/phpmyadmin/libraries>
    Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
    Require all denied
</Directory>

available with SSL through

/etc/apache2/sites-enabled/default-ssl.conf

<IfModule mod_ssl.c>
        <VirtualHost *:443>
                ServerAdmin admin@HOSTNAME_HERE.com
                ServerName ip.address.of.hostname
                DocumentRoot /var/www/HOSTNAME_HERE/wordpress/
                <Directory /var/www/HOSTNAME_HERE/wordpress/>
                     Options +FollowSymLinks
                     AllowOverride All
                     Order allow,deny
                     allow from all
                </Directory>
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
                SSLEngine on
                SSLProtocol         all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
                SSLCipherSuite      ECDHE-ECDSA-AES256-GCM-SHA384...
                SSLHonorCipherOrder on
                SSLCompression      off
                SSLSessionTickets   off
                SSLCertificateFile      /etc/apache2/ssl/certificate.crt
                SSLCertificateKeyFile /etc/apache2/ssl/pkey.key
                SSLCertificateChainFile /etc/apache2/ssl/chain-ca.crt
                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>
        </VirtualHost>
</IfModule>

/etc/apache2/sites-enabled/openproject.conf

<VirtualHost *:80>
  ServerName openproject.example.com
  DocumentRoot /opt/openproject/public

  ProxyRequests off

  Include /etc/openproject/addons/apache2/includes/vhost/*.conf

  # Can't use Location block since it would overshadow all the other proxypass directives on CentOS
  ProxyPass / http://127.0.0.1:6000/ retry=0
  ProxyPassReverse / http://127.0.0.1:6000/
</VirtualHost>

/etc/openproject/addons/apache2/includes/vhost/openproject.conf

ServerName openproject.example.com
redirect permanent / http://example.com/

ServerName      openproject.example.com
ServerAdmin     [email protected]
DocumentRoot    /opt/openproject/public

ProxyRequests off
ProxyPass / http://127.0.0.1:6000/ retry=0
ProxyPassReverse / http://127.0.0.1:6000/


<LocationMatch "^/sys">
  <IfModule mod_authz_core.c>
          Require local
  </IfModule>

  <IfModule !mod_authz_core.c>
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
  </IfModule>
</LocationMatch>

Alias /assets /opt/openproject/public/assets
Alias /uploads /opt/openproject/public/uploads
<Directory "/opt/openproject/public">
Options -Indexes
<IfModule mod_authz_core.c>
  Require all granted
</IfModule>

<IfModule !mod_authz_core.c>
  Order deny,allow
  Allow from all
</IfModule>
</Directory>

 ProxyPass /assets/ !
 <Location /assets/>
 FileETag Size
 ExpiresActive On ExpiresDefault "access plus 1 year"
 </Location>

 <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
  ExpiresActive On
  ExpiresDefault "access plus 1 year"
</FilesMatch>

AddOutputFilterByType DEFLATE text/html text/css application/x-javascript application/javascript

ErrorLog    /var/log/apache2/openproject.example.com-error.log

When I go to https://example.com everything works as expected.

When I go to http://openproject.example.com everything works as expected.

Unfortunately http://example.com shows openproject application and all other subdomains such as http://notexisting.example.com

Rule for http://example.com is to be redirected to https://example.com

How to configure it as expected?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.