Multiple subdomains with multiple web roots, all redirect to the same thing?


#1

Hello, I’ve setup Let’s Encrypt on my server on 4 sub domains that each have a different web root path as one cert, now I’m setting up the Apache vhost file but it’s just not working, basically this is what I’m doing

The SSL conf has
mydomain.net
sub1.mydomain.net
sub2.mydomain.net
sub3.mydomain.net

Each to it’s own path, but whenever I go to any of the subdomains I always get redirected to the main domain itself, any help? I reset my vhosts file now so I can’t show it unfortunately.


#2

What have you reset the vhosts file to ?

Your browser may well have cached the redirects as well - so you may need to clear your browser cache


#3

Actually I got it fixed now, the 443 port was overlapping since it had multiple vhosts, but I’m having another issue now, HTTPS isn’t forcing, not sure if it’s because of cache or not


#4

without your domain name or config it’s impossible to say.

Have you configured it in the config ( or .htaccess ) to force https ?


#5

My config is huge (1000+ lines lol) so idk how to share it.

No I have not, can you I know what to add to it to force it please?


#6

http://pastebin.com/ is probably the easiest

No I have not, can you I know what to add to it to force it please?

without any information about your setup - not really. Are you using apache ? or nginx ? or something else ?


#7

I am using Apache2 and Cloudflare, sorry for misleading.


#8

and are you using cloudflare purely for DNS ? or are you using it as a cache for your site ?


#9

Purely for DNS and DDoS protection


#10

That doesn’t make sense …

if you are using it for DDoS protection, then cloudflare are caching your site, and providing it to the users

if you are using it purely for DNS, then the users are redirected to your server ( and not cached by cloudflare) in which case cloudflare aren’t providing ddos protection.

What is your domain name ?


#11

I am gonna PM you with some info


#12

I don’t know, if everything’s right now. So my let me help with an example. I understood, that you wanted to redirect to the https-part of your page, but not to the root. You wanted to do this:
http://mydomain.net -> https://mydomain.net
http://sub1.mydomain.net -> https://sub1.mydomain.net
http://sub2.mydomain.net -> https://sub2.mydomain.net
http://sub3.mydomain.net -> https://sub3.mydomain.net
Am I right? If yes, look at the example configuration I prepared for you.

/etc/apache2/sites-enabled/http-based.conf:
<VirtualHost *:80> ServerAlias <your-domain> www.<your-domain> ## enable this, to ALLWAYS redirect to https #Redirect permanent / https://mail.<your-domain>/ ## enable this, to not autmaticly redirect https #DocumentRoot "/var/www/domains/<your-domain>" #ErrorLog ${APACHE_LOG_DIR}/<your-domain>-error.log #CustomLog ${APACHE_LOG_DIR}/<your-domain>-access.log combined </VirtualHost> <VirtualHost *:80> ServerAlias mail.<your-domain> roundcube.<your-domain> Redirect permanent / https://mail.<your-domain>/ </VirtualHost>

/etc/apache2/sites-enabled/https-based.conf:
<IfModule mod_ssl.c> <VirtualHost *:443> ServerName <your-domain> DocumentRoot ... ErrorLog ${APACHE_LOG_DIR}/<your-domain>-error.log CustomLog ${APACHE_LOG_DIR}/<your-domain>-access.log combined SSLEngine on SSLCertificateFile /etc/letsencrypt/live/<your-domain>/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/<your-domain>/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/<your-domain>/chain.pem </VirtualHost> <VirtualHost *:443> ServerName www.<your-domain> DocumentRoot ... ErrorLog ${APACHE_LOG_DIR}/<your-domain>-error.log CustomLog ${APACHE_LOG_DIR}/<your-domain>-access.log combined SSLEngine on SSLCertificateFile /etc/letsencrypt/live/<your-domain>/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/<your-domain>/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/<your-domain>/chain.pem </VirtualHost> <VirtualHost *:443> ServerName mail.<your-domain> DocumentRoot ... ErrorLog ${APACHE_LOG_DIR}/<your-domain>-error.log CustomLog ${APACHE_LOG_DIR}/<your-domain>-access.log combined SSLEngine on SSLCertificateFile /etc/letsencrypt/live/roundcube.<your-domain>/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/roundcube.<your-domain>/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/roundcube.<your-domain>/chain.pem </VirtualHost> <VirtualHost *:443> ServerName roundcube.<your-domain> DocumentRoot ... ErrorLog ${APACHE_LOG_DIR}/<your-domain>-error.log CustomLog ${APACHE_LOG_DIR}/<your-domain>-access.log combined SSLEngine on SSLCertificateFile /etc/letsencrypt/live/roundcube.<your-domain>/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/roundcube.<your-domain>/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/roundcube.<your-domain>/chain.pem </VirtualHost> </IfModule>


#13

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.