I have shellinabox running on a subdomain through HTTPS and using HTTP Basic Access Authentication using the vhosts file below:

<VirtualHost xx.xx.xx.xx:80>
        ServerName              host.bananas.net
        Redirect                301 / https://host.bananas.net
        CustomLog               ${APACHE_LOG_DIR}/access.log combined
        ErrorLog                ${APACHE_LOG_DIR}/error.log
</VirtualHost.net>

<VirtualHost xx.xx.xx.xx:443>
        ServerName              host.bananas.net
        SSLEngine               On
        SSLCertificateFile      /etc/apache2/ssl/bananas.net.crt
        SSLCertificateKeyFile   /etc/apache2/ssl/bananas.net.key
        SSLCertificateChainFile /etc/apache2/ssl/sub.class1.server.ca.pem
        SSLCACertificateFile    /etc/apache2/ssl/ca.pem
        SetEnvIf                User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
        ProxyRequests           Off
        ProxyPass               / http://localhost:4200/
        ProxyPassReverse        / http://localhost:4200/
        <Location />
                AuthUserFile    /etc/apache2/.htpasswd-secure
                AuthName        "Go Away!"
                AuthType        Basic
                Require         valid-user
                Order           Deny,Allow
                Allow           from all
        </Location>
        SetEnvIf                Request_URI "^/u" dontlog
        HostnameLookups         Double
        CustomLog               ${APACHE_LOG_DIR}/ssl_request.log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
        ErrorLog                ${APACHE_LOG_DIR}/error.log
</VirtualHost>

I currently have another site on another subdomain, using this vhosts file:

<VirtualHost xx.xx.xx.xx:80>
        ServerName              files.bananas.net
        DocumentRoot            /var/www/files.bananas.net/

        CustomLog               ${APACHE_LOG_DIR}/access.log combined
        ErrorLog                ${APACHE_LOG_DIR}/error.log
</VirtualHost>

I would prefer to have the second site available at https://host.bananas.net/files instead of http://files.bananas.net.

The main reason for this is so that I can use the same SSL certificate, but there are other reasons as well.

How do I move the second site to be a subdirectory of the first site?

link|improve this question

67% accept rate
feedback

1 Answer

up vote 2 down vote accepted

Exempt /files from the proxying:

ProxyPass /files !

Put it above the root's ProxyPass. Looks like you'll also need to adjust your DocumentRoots or file structure as needed to serve the content from the SSL vhost.

link|improve this answer
What should I make the DocumentRoot, now that the site within /files/ is not at the root? What needs to run is https://bananas.net/files/index.php. – paradroid Sep 9 '11 at 19:25
If you want to keep the files.bananas.net host in place, then just point at that location in the directory structure; Alias /files /var/www/files.bananas.net. Your authentication config from <Location /> will still be applying, too; if that's not desired then undo that config in a <Location /files> block. – Shane Madden Sep 9 '11 at 19:29
I have already moved the site's files to /var/www/host.bananas.net/files/, which I prefer. How should I set a DocumentRoot for https://bananas.net/files/index.php? Thanks. – paradroid Sep 9 '11 at 19:33
DocumentRoot /var/www/host.bananas.net should do the trick. – Shane Madden Sep 9 '11 at 19:34
Thanks, that worked. – paradroid Sep 9 '11 at 19:40
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.