Ok, I have a bit of a complicated set up that works for the most part, but recently I've had to migrate a couple sites to my server and I can't seem to get things working the way I want.
I have 5 websites that I'm hosting from my server. I initially had 3. We'll call them
- example.com
- files.example.com
- git.example.com
- temp.alagory.com
- temp.minceraft.com
alagory.com
and minceraft.com
are the sites that I'm migrating over to my personal server. My personal server doesn't have a static IP address, so I've set it up with DDNS which gives it the address example.com
with the two subdomains files, and git. These three DDNS domains I want to have under SSL. temp.alagory.com
and temp.minceraft.com
are WordPress sites, and since I'm making them public, I do not want everybody visiting them being confronted by a warning about my self-signed certificate. I also would like to not spend the cheap fee to get an official accredited certificate. Initially, I've been able to get the three DDNS sites working (*.example.com
) all of which play nicely under a blanket of encryption. The other two sites worked nicely on their server that I've decided to do away with.
The trouble comes when I try to host all these sites with all their differences under one server.
I set up temp.alagory.com
and temp.minceraft.com
with CNAME type records pointing to example.com
. I've been successfully utilizing virtual hosts on the other three domains to send them to their respective sites. I set up the virtual hosts for allegory
and minceraft
pointing them to their directories, but they resolve to /srv/http
, which is the directory for example.com
. Also, the domains are redirected to be encrypted with my certificate. I don't really understand how since they are not the names I used in the certificate. I thought that was something that was checked.
Here is the virtual host configuration file for git.example.com
#This configuration has been tested on GitLab 6.0.0 and GitLab 6.0.1
#Note this config assumes unicorn is listening on default port 8080.
#Module dependencies
# mod_rewrite
# mod_proxy
# mod_proxy_http
<VirtualHost *:80>
ServerName git.example.com
ServerSignature Off
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [NE,R,L]
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
#strong encryption ciphers only
#see ciphers(1) http://www.openssl.org/docs/apps/ciphers.html
SSLProtocol all -SSLv2
SSLHonorCipherOrder on
# SSLCipherSuite "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM :RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS"
SSLCipherSuite SSLv3:TLSv1:+HIGH:!SSLv2:!MD5:!MEDIUM:!LOW:!EXP:!ADH:!eNULL:!aNULL
Header add Strict-Transport-Security: "max-age=15768000;includeSubdomains"
SSLCompression Off
SSLCertificateFile /etc/httpd/conf/server.crt
SSLCertificateKeyFile /etc/httpd/conf/server.key
SSLCACertificateFile /etc/httpd/conf/server.crt
ServerName git.example.com
ServerSignature Off
ProxyPreserveHost On
<Location />
# New authorization commands for apache 2.4 and up
# http://httpd.apache.org/docs/2.4/upgrading.html#access
Require all granted
ProxyPassReverse http://127.0.0.1:8080
ProxyPassReverse http://git.example.com/
</Location>
#apache equivalent of nginx try files
# http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try- files
# http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA]
RequestHeader set X_FORWARDED_PROTO 'https'
# needed for downloading attachments
DocumentRoot /usr/share/webapps/gitlab/public
#Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.
ErrorDocument 404 /404.html
ErrorDocument 422 /422.html
ErrorDocument 500 /500.html
ErrorDocument 503 /deploy.html
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
ErrorLog /var/log/httpd/git.example.com_error.log
CustomLog /var/log/httpd/git.example.com_forwarded.log common_forwarded
CustomLog /var/log/httpd/git.example.com_access.log combined env=!dontlog
CustomLog /var/log/httpd/git.example.com.log combined
</VirtualHost>
Here is the configuration I've been using to sort files.example.com
, example.com
, temp.alagory.com
, and temp.minceraft.com
:
Virtual hosts for my other sites
And here is my httpd.conf
I've tried to use temp.alagory.com
as the server name for the temp.alagory.com
virtual host, but it still redirected to the /srv/http/
directory. I've tried removing all other configurations but it still resolves to the default directory /srv/http/
.
Here is the output of apachectl -S
with the names of the corresponding sites replaced:
[root@Vega extra]# apachectl -S
VirtualHost configuration:
*:80 is a NameVirtualHost
default server example.com (/etc/httpd/conf/extra/httpd-vhosts.conf:25)
port 80 namevhost example.com (/etc/httpd/conf/extra/httpd-vhosts.conf:25)
alias temp.alagory.com
wild alias *.temp.alagory.com
port 80 namevhost example.com (/etc/httpd/conf/extra/httpd-vhosts.conf:36)
alias temp.minceraft.com
wild alias *.temp.minceraft.com
port 80 namevhost localhost.localdomain (/etc/httpd/conf/extra/httpd- vhosts.conf:47)
port 80 namevhost example.com (/etc/httpd/conf/extra/httpd-vhosts.conf:70)
port 80 namevhost git.example.com (/etc/httpd/conf/extra/gitlab.conf:8)
*:443 is a NameVirtualHost
default server files.example.com (/etc/httpd/conf/extra/httpd- vhosts.conf:57)
port 443 namevhost files.example.com (/etc/httpd/conf/extra/httpd- vhosts.conf:57)
port 443 namevhost example.com (/etc/httpd/conf/extra/httpd- vhosts.conf:80)
port 443 namevhost git.example.com (/etc/httpd/conf/extra/gitlab.conf:16)
port 443 namevhost www.example.com (/etc/httpd/conf/extra/httpd-ssl.conf:80)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/srv/http"
Main ErrorLog: "/var/log/httpd/error_log"
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="http" id=33
Group: name="http" id=33