Skip to content

Instantly share code, notes, and snippets.

@dolanor
Created November 22, 2012 10:16
Show Gist options
  • Save dolanor/4130399 to your computer and use it in GitHub Desktop.
Save dolanor/4130399 to your computer and use it in GitHub Desktop.
Apache2 configuration for multiple subdomains pointing to different local ports with SSL

#Apache2 and bind configuration for subdomain for each web application running on different port

<VirtualHost *:80>
ServerName gitlab.domain.tld
Redirect / https://gitlab.domain.tld/
CustomLog /var/log/apache2/gitlab/access.log combined
ErrorLog /var/log/apache2/gitlab/error.log
</VirtualHost>
NameVirtualHost *:443
<VirtualHost *:443>
ServerName gitlab.domain.tld
ServerAdmin [email protected]
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/cert-gitlab.domain.tld.crt
SSLCertificateKeyFile /etc/apache2/ssl/key-gitlab.domain.tld.key
SSLProxyEngine on
SSLProxyCACertificateFile /etc/apache2/ssl/cert-gitlab.domain.tld.crt
ProxyRequests On
ProxyPreserveHost On
ProxyVia full
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
CustomLog /var/log/apache2/gitlab/access.log combined
ErrorLog /var/log/apache2/gitlab/error.log
</VirtualHost>
<VirtualHost *:443>
ServerName shellinabox.domain.tld
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/cert-sh.domain.tld.crt
SSLCertificateKeyFile /etc/apache2/key-sh.domain.tld.key
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:4200/
ProxyPassReverse / http://localhost:4200/
</VirtualHost>
/etc/bind/db.domain.tld
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA ns.domain.tld. root.domain.tld. (
20121101014103 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns.domain.tld.
; Mandatory to get an access in http://domain.tld without servername before
IN A 123.255.231.128
ns IN A 123.255.231.128
ns IN AAAA ipv6:adde:55:::::
gitlab IN A 123.255.231.128
* IN A 123.255.231.128
* IN AAAA ipv6:adde:55:::::
@ IN SOA domain.tld. admin.domain.tld. (
2006081401;
28800;
604800;
604800;
86400);
IN NS ns.domain.tld.
66 IN PTR domain.tld.
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone "domain.tld" {
type master;
file "/etc/bind/db.domain.tld";
};
zone "0.231.255.123.in-addr.arpa" {
type master;
file "/etc/bind/db.domain.tld.inv";
};
<VirtualHost *:80>
ServerName gitlab.domain.tld
Redirect / https://gitlab.domain.tld/
CustomLog /var/log/apache2/gitlab/access.log combined
ErrorLog /var/log/apache2/gitlab/error.log
</VirtualHost>
NameVirtualHost *:443
<VirtualHost *:443>
ServerName gitlab.domain.tld
ServerAdmin [email protected]
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/cert-gitlab.domain.tld.crt
SSLCertificateKeyFile /etc/apache2/ssl/key-gitlab.domain.tld.key
SSLProxyEngine on
SSLProxyCACertificateFile /etc/apache2/ssl/cert-gitlab.domain.tld.crt
ProxyRequests On
ProxyPreserveHost On
ProxyVia full
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
CustomLog /var/log/apache2/gitlab/access.log combined
ErrorLog /var/log/apache2/gitlab/error.log
</VirtualHost>
<VirtualHost *:443>
ServerName shellinabox.domain.tld
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/cert-sh.domain.tld.crt
SSLCertificateKeyFile /etc/apache2/key-sh.domain.tld.key
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:4200/
ProxyPassReverse / http://localhost:4200/
</VirtualHost>
/etc/bind/db.domain.tld
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA ns.domain.tld. root.domain.tld. (
20121101014103 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns.domain.tld.
; Mandatory to get an access in http://domain.tld without servername before
IN A 123.255.231.128
ns IN A 123.255.231.128
ns IN AAAA ipv6:adde:55:::::
gitlab IN A 123.255.231.128
* IN A 123.255.231.128
* IN AAAA ipv6:adde:55:::::
@ IN SOA domain.tld. admin.domain.tld. (
2006081401;
28800;
604800;
604800;
86400);
IN NS ns.domain.tld.
66 IN PTR domain.tld.
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone "domain.tld" {
type master;
file "/etc/bind/db.domain.tld";
};
zone "0.231.255.123.in-addr.arpa" {
type master;
file "/etc/bind/db.domain.tld.inv";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment