Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: Apache VirtualHosts not working correctly |
|
Author |
|
declan.marks
Joined: 15 Aug 2017 Posts: 1 Location: United Kingdom, Norwich
|
Posted: Tue 15 Aug '17 11:45 Post subject: Apache VirtualHosts not working correctly |
|
|
I have installed Nextcloud and installed in a VirtualHost in the nextcloud.conf (See configuration below). When I only have on VirtualHost (nextcloud.conf) enabled in Apache on Ubuntu 16.04, it works. I can browse to storage.declanmarks.pw. But when I enable the 000-default.conf and the default-ssl.conf it keeps taking me to the main page when I navigate to storage.declanmarks.pw, not the Nextcloud page. I have posted all my configuration files. I want to get the default [/code] working because I want to catch all urls that don't match the Nextcloud configuration.
nextcloud.conf
Code: | <VirtualHost *:80>
ServerName storage.declanmarks.pw
RewriteEngine On
RewriteCond %{HTTP_HOST} ^storage.declanmarks.pw
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
#RewriteRule ^(.*)$ https://storage.declanmarks.pw$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
Alias /files /var/www/files
ServerName storage.declanmarks.pw
DocumentRoot /var/www/nextcloud/
ServerAlias storage.declanmarks.pw
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</Directory>
# SSL
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/storage.declanmarks.pw/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/storage.declanmarks.pw/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/storage.declanmarks.pw/fullchain.pem
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
|
default-ssl.conf
Code: |
<VirtualHost *:443>
DocumentRoot /var/www/main
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# SSL
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/storage.declanmarks.pw/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/storage.declanmarks.pw/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/storage.declanmarks.pw/fullchain.pem
</VirtualHost>
|
000-default.conf
Code: |
<VirtualHost *:80>
DocumentRoot /var/www/main
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
|
I can't figure out why it is not working. |
|
Back to top |
|
Qmpeltaty
Joined: 06 Feb 2008 Posts: 182 Location: Poland
|
Posted: Fri 18 Aug '17 13:19 Post subject: |
|
|
First of all change the http/80 virtualhost for nextcloud to
Code: |
<VirtualHost *:80>
ServerName storage.declanmarks.pw
Redirect permanent / https://storage.declanmarks.pw/
</VirtualHost>
|
It will consume less resources than mod_rewrite.
To fix your issue change the name of the files and spread http with https to separate files for nextcloud in the same like it's for default vhost.
000-nextcloud.conf - http
001-nextcloud-ssl.conf - https
002-default.conf - http
003-default-ssl.conf - https |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
|
Back to top |
|
|
|
|
|
|