LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-16-2023, 05:31 AM   #1
pr0xibus
Member
 
Registered: Apr 2004
Location: Scotland
Distribution: Slackware
Posts: 215

Rep: Reputation: 44
Slackware - Httpd - Lets Encrypt - Multiple Domains


Morning Folks.

I had initially set this up with a single domain and it worked perfectly, but when adding a second domain I have issues.
I have managed to get the ssl cert from lets encrypt for both domains, when i visit domain1 its perfect, 80 and 443, when I visit domain2 it defaults to 80 and when i visit domain2:443 it redirects me to domain1. I have very little knowledge in httpd, below is my Vhost. Cleared browser cache on 2 different devices, but still the same issue, can anyone seem to spot issues below?

Code:
#########################################################################
#  VHost for NON HTTPS, port 80 only, has a permanent redirect to https #
#########################################################################
<VirtualHost *:80>
    ServerName domain1.co.uk
    ServerAlias www.domain1.co.uk
    ServerAdmin myemail
    DocumentRoot /srv/httpd/domain1.co.uk

    Alias /.well-known/acme-challenge /usr/local/dehydrated
    <Directory /usr/local/dehydrated>
	Options None
	AllowOverride None
	Require all granted
    </Directory>
    
    #Redirect permanent "/" "https://www.domain1.co.uk"
</VirtualHost>

<VirtualHost *:80>
    ServerName domain2.co.uk
    ServerAlias www.domain2.co.uk
    DocumentRoot /srv/httpd/domain2.co.uk/

    Alias /.well-known/acme-challenge /usr/local/dehydrated
    <Directory /usr/local/dehydrated>
	Options None
	AllowOverride None
	Require all granted
    </Directory>

    #Redirect permanent "/" "https://www.domain2.co.uk"
</VirtualHost>

#########################################################################
# VHost for HTTPS, Port 443	 domain1.co.uk			#
#########################################################################
<VirtualHost *:443>
    DocumentRoot "/srv/httpd/domain1.co.uk/"
    ServerName www.domain1.co.uk
    ServerAdmin myemail
    
    <FilesMatch "\.(html|php)$">
	SSLOptions
    </FilesMatch>

    Alias /.well-known/acme-challenge /usr/local/dehydrated
    <Directory /usr/local/dehydrated>
	Options None
	AllowOverride None
	Require all granted
    </Directory>

SSLEngine on
SSLCertificateFile /etc/dehydrated/certs/www.domain1.co.uk/cert.pem
SSLCertificateKeyFile /etc/dehydrated/certs/www.domain1.co.uk/privkey.pem
SSLCertificateChainFile /etc/dehydrated/certs/www.domain1
SSLCACertificateFile /etc/ssl/certs/ca-certificates.crt

</VirtualHost>


#########################################################################
# VHost for HTTPS, Port 443	 domain2.co.uk				#
#########################################################################
<VirtualHost *:443>
    DocumentRoot "/srv/httpd/domain2.co.uk/"
    ServerName www.domain2.co.uk
    ServerAdmin myemail

    <FilesMatch "\.(html|php)$">
	SSLOptions
    </FilesMatch>

    Alias /.well-known/acme-challenge /usr/local/dehydrated
    <Directory /usr/local/dehydrated>
	Options None
	AllowOverride None
	Require all granted
    </Directory>

SSLEngine on
SSLCertificateFile /etc/dehydrated/certs/www.domain2.co.uk/cert.pem
SSLCertificateKeyFile /etc/dehydrated/certs/www.domain2.co.uk/privkey.pem
SSLCertificateChainFile /etc/dehydrated/certs/www.domain2.co.uk/chain.pem
SSLCACertificatePath /etc/ssl/certs
SSLCACertificateFile /etc/ssl/certs/ca-certificates.crt

</VirtualHost>
 
Old 12-16-2023, 12:35 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,175
Blog Entries: 1

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Quote:
Originally Posted by pr0xibus View Post
Morning Folks.

I had initially set this up with a single domain and it worked perfectly, but when adding a second domain I have issues.
I have managed to get the ssl cert from lets encrypt for both domains, when i visit domain1 its perfect, 80 and 443, when I visit domain2 it defaults to 80 and when i visit domain2:443 it redirects me to domain1. I have very little knowledge in httpd, below is my Vhost. Cleared browser cache on 2 different devices, but still the same issue, can anyone seem to spot issues below?

Code:
#########################################################################
#  VHost for NON HTTPS, port 80 only, has a permanent redirect to https #
#########################################################################
<VirtualHost *:80>
    ServerName domain1.co.uk
    ServerAlias www.domain1.co.uk
    ServerAdmin myemail
    DocumentRoot /srv/httpd/domain1.co.uk

    Alias /.well-known/acme-challenge /usr/local/dehydrated
    <Directory /usr/local/dehydrated>
	Options None
	AllowOverride None
	Require all granted
    </Directory>
    
    #Redirect permanent "/" "https://www.domain1.co.uk"
</VirtualHost>

<VirtualHost *:80>
    ServerName domain2.co.uk
    ServerAlias www.domain2.co.uk
    DocumentRoot /srv/httpd/domain2.co.uk/

    Alias /.well-known/acme-challenge /usr/local/dehydrated
    <Directory /usr/local/dehydrated>
	Options None
	AllowOverride None
	Require all granted
    </Directory>

    #Redirect permanent "/" "https://www.domain2.co.uk"
</VirtualHost>

#########################################################################
# VHost for HTTPS, Port 443	 domain1.co.uk			#
#########################################################################
<VirtualHost *:443>
    DocumentRoot "/srv/httpd/domain1.co.uk/"
    ServerName www.domain1.co.uk
    ServerAdmin myemail
    
    <FilesMatch "\.(html|php)$">
	SSLOptions
    </FilesMatch>

    Alias /.well-known/acme-challenge /usr/local/dehydrated
    <Directory /usr/local/dehydrated>
	Options None
	AllowOverride None
	Require all granted
    </Directory>

SSLEngine on
SSLCertificateFile /etc/dehydrated/certs/www.domain1.co.uk/cert.pem
SSLCertificateKeyFile /etc/dehydrated/certs/www.domain1.co.uk/privkey.pem
SSLCertificateChainFile /etc/dehydrated/certs/www.domain1
SSLCACertificateFile /etc/ssl/certs/ca-certificates.crt

</VirtualHost>


#########################################################################
# VHost for HTTPS, Port 443	 domain2.co.uk				#
#########################################################################
<VirtualHost *:443>
    DocumentRoot "/srv/httpd/domain2.co.uk/"
    ServerName www.domain2.co.uk
    ServerAdmin myemail

    <FilesMatch "\.(html|php)$">
	SSLOptions
    </FilesMatch>

    Alias /.well-known/acme-challenge /usr/local/dehydrated
    <Directory /usr/local/dehydrated>
	Options None
	AllowOverride None
	Require all granted
    </Directory>

SSLEngine on
SSLCertificateFile /etc/dehydrated/certs/www.domain2.co.uk/cert.pem
SSLCertificateKeyFile /etc/dehydrated/certs/www.domain2.co.uk/privkey.pem
SSLCertificateChainFile /etc/dehydrated/certs/www.domain2.co.uk/chain.pem
SSLCACertificatePath /etc/ssl/certs
SSLCACertificateFile /etc/ssl/certs/ca-certificates.crt

</VirtualHost>
Did you remember to restart apache after making changes to config files?
You can run the following command to see what vhosts are currently configured:
Code:
apachectl -S
Regards
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to fully automate renewing of Let’s Encrypt certificates for multiple sites with Ruby and Let’s Encrypt ACMEv2 protocol LXer Syndicated Linux News 0 04-02-2020 04:32 AM
httpd: Syntax error on line 210 of /etc/httpd/conf/httpd.conf: Syntax error on line 6 iswarya Linux - Newbie 1 01-25-2012 01:28 PM
Multiple emails accounts(with different from domains) on multiple domains on 1 server locoputo Linux - Server 0 04-12-2009 06:29 PM
Starting httpd: httpd: Syntax error on line 209 of /etc/httpd/conf/httpd.conf: Syntax sethukpathi Linux - Networking 6 04-12-2008 11:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration