Last active
March 21, 2018 15:35
-
-
Save niraj-shah/35a1fa990dadbee40b382d8a7a50f2fe to your computer and use it in GitHub Desktop.
Apache2 vhost and site config setup. `mydomain-ssl.conf` is the SSL site conf, `mydomain.conf` is the regular site conf, and `mydomain.vhost` is the vhost found in `/etc/apache2/conf/vhosts`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_ssl.c> | |
<VirtualHost *:443> | |
Include conf/vhosts/mydomain.vhost | |
SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem | |
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem | |
Include /etc/letsencrypt/options-ssl-apache.conf | |
</VirtualHost> | |
</IfModule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
Include conf/vhosts/mydomain.vhost | |
</VirtualHost> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ServerAdmin [email protected] | |
ServerName mydomain.com | |
UseCanonicalName on | |
ServerAlias www.mydomain.com | |
DocumentRoot /var/www/ | |
<Directory /> | |
Options +FollowSymLinks | |
AllowOverride All | |
</Directory> | |
<Directory /var/www > | |
Options -Indexes | |
Require all granted | |
</Directory> | |
RewriteEngine On | |
# force non-www | |
RewriteCond %{HTTP_HOST} ^www [NC] | |
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] | |
# force https | |
RewriteCond %{HTTPS} off | |
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [R,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment