logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache 2 (Debian) config - driving me nuts!
Author
pointer2null



Joined: 27 Nov 2015
Posts: 3
Location: UK, Bristol

PostPosted: Fri 27 Nov '15 21:53    Post subject: Apache 2 (Debian) config - driving me nuts! Reply with quote

Hi everyone - just signed up.

Been using Apache 2 for my home server for a few years but always seem to have problems with the config. I can normally get it working, but more by luck than design.

I've just moved the sever to a new OS (Ubuntu -> Debian) so it should be simple. Ha! No.

I've tried working my way through this as I need to understand the config files but I never quite seem to get it right.

(In all of this, please consider the possibility of "operator error". Sometimes I can't see the wood for the trees!)

So, this is the situation. I want to be able to have a range of different pages and subdomains running. I've got all my DNS records set up correct (domain and subdomain all point to my ip) and my router is set to forward all port 80 and 443 to my webserver.

My webpages and subdomians

http://www.myserver.co.uk
Just a simple web page. Doc root /var/www/html/publicpages

https://www.myserver.co.uk
Almost the same, but secure and with simple password verficiation. Doc root /var/www/html/privatepages

https://cloud.myserver.co.uk
Subdomain hosting ownCloud server. Also needs a redirect from http to https

https://shares.myserver.co.uk
Pydio file server.

This shouldn't be hard. I had it working before. The cloud subdomain works fine as does the https home page, but now if I try and connect on the public http://www.myserver.co.uk I just get bounced direct to the cloud subdomain.

So my config files:

000-default.conf

Code:

<VirtualHost *:80>
        ServerName myserver.co.uk

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

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

</VirtualHost>



default-ssl.conf

Code:

<IfModule mod_ssl.c>
   <VirtualHost _default_:443>
        ServerAdmin barackobama@gmail.com
        ServerName myserver.co.uk
        ServerAlias www.myserver.co.uk
        DocumentRoot /var/www/html/private
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/apache.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache.key
        <FilesMatch "\.(cgi|shtml|phtml|php)$">
          SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
          SSLOptions +StdEnvVars
        </Directory>
        BrowserMatch "MSIE [2-6]" \
                        nokeepalive ssl-unclean-shutdown \
                        downgrade-1.0 force-response-1.0
        # MSIE 7 and newer should be able to use keepalive
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
        <Location / >
           AuthType Basic
           AuthName "Drop em!"
           AuthUserFile /etc/apache2/xxserver.auth
           Require valid-user
        </Location>
     </VirtualHost>
</IfModule>





cloud_vhost443.conf

Code:


<VirtualHost *:80>
   ServerName cloud.myserver.co.uk
   DocumentRoot /var/www/owncloud
   Redirect permanent / https://cloud.myserver.co.uk
</VirtualHost>

<VirtualHost *:443>
  ServerName cloud.myserver.co.uk
  SSLEngine On
  SSLCertificateFile /etc/apache2/ssl/apache.crt
  SSLCertificateKeyFile /etc/apache2/ssl/apache.key
  DocumentRoot /var/www/owncloud
  <Directory /var/www/owncloud>
    AllowOverride All
    Options +FollowSymLinks
    Order Deny,Allow
    Allow from all
    SSLRequireSSL
  </Directory>
</VirtualHost>



apache2ctl output:

Code:

root# apache2ctl -S
VirtualHost configuration:
*:80                   myserver.co.uk (/etc/apache2/sites-enabled/000-default.conf:1)
*:443                  is a NameVirtualHost
         default server cloud.myserver.co.uk (/etc/apache2/sites-enabled/cloud_vhost443.conf:7)
         port 443 namevhost cloud.myserver.co.uk (/etc/apache2/sites-enabled/cloud_vhost443.conf:7)
         port 443 namevhost myserver.co.uk (/etc/apache2/sites-enabled/default-ssl.conf:2)
                 alias www.myserver.co.uk
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33


If I've forgotten any config files then let me know and I'll post them.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Sat 28 Nov '15 10:47    Post subject: Reply with quote

you need a second vhost on port 80 for the cloud domain. And in that vhost create the redicrect to the SSL vhost.
Back to top
pointer2null



Joined: 27 Nov 2015
Posts: 3
Location: UK, Bristol

PostPosted: Sat 28 Nov '15 11:23    Post subject: Reply with quote

Haven't I alreayd got that?

<VirtualHost *:80>
ServerName cloud.myserver.co.uk
DocumentRoot /var/www/owncloud
Redirect permanent / https://cloud.myserver.co.uk
</VirtualHost>
Back to top
pointer2null



Joined: 27 Nov 2015
Posts: 3
Location: UK, Bristol

PostPosted: Sat 28 Nov '15 12:36    Post subject: Reply with quote

See I did say it could be operator error.

Well, not quite. Turns out the cache in FF had got in a muddle so when trying to access the public site it was doing a redirect to the subdomain.

Clearing the cache, disabling all sites and starting with the public site, adding them one at a time seems to have resolved the issue.

Thanks for the suggestion anyhow.
Back to top


Reply to topic   Topic: Apache 2 (Debian) config - driving me nuts! View previous topic :: View next topic
Post new topic   Forum Index -> Apache