0

I admit I am quite rusty with these apache server setups. I am in a position where I need to set up 1 html, 1 django, and 1 php server. Individually I have tested all 3 and all 3 work fine on their own, but I am just not getting something right when I am trying to run all 3. I need one subdomain specifically to be redirected to https. Initially I had a permanent redirect on all http requests to port 443 because that's all I needed.

default.conf

<VirtualHost *:80>
        ServerName owncloud.website.net
        Redirect permanent / 'https://owncloud.website.net:50443'
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Going over this was kind of helpful but at the same time, it didn't really answer any questions. You just kind of assume that the apache server figures out which files to serve based on the domain name entered into the users browser (ServerName). https://httpd.apache.org/docs/2.4/vhosts/examples.html

I started picking away at the conf file by trying to add in additional virtual hosts like this:

default.conf

<VirtualHost *:80>
        ServerName website.net
        DocumentRoot /cloud/web/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

levenas.conf

<VirtualHost *:80>
        ServerName django.website.net
        DocumentRoot /cloud/web/levenasprojdir/levenasproj
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        Alias /static /cloud/web/levenasprojdir/static
        <Directory /cloud/web/levenasprojdir/static>
                Require all granted
        </Directory>

        Alias /static /cloud/web/levenasprojdir/media
        <Directory /cloud/web/levenasprojdir/media>
                Require all granted
        </Directory>

        <Directory /cloud/web/levenasprojdir/levenasproj>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        WSGIDaemonProcess django_project python-path=/cloud/web/levenasprojdir python-home=/cloud/web/levenasprojdir/env
        WSGIProcessGroup django_project
        WSGIScriptAlias / /cloud/web/levenasprojdir/levenasproj/wsgi.py
</VirtualHost>

owncloud.conf

<VirtualHost *:80 *:443>
        ServerName owncloud.website.net
        Redirect permanent / 'https://owncloud.website.net:50443'
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Alias / "/cloud/web/owncloud/"

<Directory /cloud/web/owncloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off
 </IfModule>

 SetEnv HOME /cloud/web/owncloud
 SetEnv HTTP_HOME /cloud/web/owncloud
</Directory>

The idea here being that the subdomains will be exclusive to their projects, and everything else gets the default landing page. I'm failing miserably though. No matter what I seem to do, the redirect takes priority and pushes users to the SSL page unintentionally. Id assumed that ServerName/ is what would be redirected, but it seems to just redirect anything. So my question here is how do I properly set up my confs such that it does the aforementioned: django subdomain serves one project, owncloud secured subdomain serves another, owncloud unsecured subdomain redirects to secured, otherwise the default site is selected?

For transparency, this is a home server, which is why you see ports like 50080 in the redirect url. 50080 is to get past my ISP and is forwarded to port 80 on the server.

1 Answer 1

0

You were ambiguous on what the issue actually is (errors on start, not redirecting??)

That <VirtualHost *:80 *:443> on owncloud config ain't gonna float with SSL and non SSL at the same time.

At the moment, are serving plain HTTP on 80 and 443 both.

You need to setup distinct VirtualHosts for plain HTTP and for HTTPS with the dreaded apache SSL configs for the latter (certificates and stuff, even for a simple redirect).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .