Use the server name as variable

This commit is contained in:
shibayashi 2018-11-03 23:41:37 +01:00
parent 007f1c73b1
commit 56c49513e0
No known key found for this signature in database
GPG Key ID: C10662A33EB28508
3 changed files with 18 additions and 16 deletions

View File

@ -22,7 +22,7 @@ social.domain.tld {
Referrer-Policy "same-origin" Referrer-Policy "same-origin"
Strict-Transport-Security "max-age=31536000; includeSubDomains;" Strict-Transport-Security "max-age=31536000; includeSubDomains;"
Expect-CT "enforce, max-age=2592000" Expect-CT "enforce, max-age=2592000"
Content-Security-Policy "default-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; img-src 'self' data: https:; media-src 'self' https:; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self'; connect-src 'self' wss://social.domain.tld; upgrade-insecure-requests;" Content-Security-Policy "default-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; img-src 'self' data: https:; media-src 'self' https:; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self'; connect-src 'self' wss://{host}; upgrade-insecure-requests;"
} }
# If you do not want remote frontends to be able to access your Pleroma backend server, remove these lines. # If you do not want remote frontends to be able to access your Pleroma backend server, remove these lines.

View File

@ -1,24 +1,26 @@
#Example configuration for when Apache httpd and Pleroma are on the same host. #Example configuration for when Apache httpd and Pleroma are on the same host.
#Needed modules: headers proxy proxy_http proxy_wstunnel rewrite ssl #Needed modules: define headers proxy proxy_http proxy_wstunnel rewrite ssl
#This assumes a Debian style Apache config. Put this in /etc/apache2/sites-available #This assumes a Debian style Apache config. Put this in /etc/apache2/sites-available
#Install your TLS certificate, possibly using Let's Encrypt. #Install your TLS certificate, possibly using Let's Encrypt.
#Replace 'pleroma.example.com' with your instance's domain wherever it appears #Replace 'pleroma.example.com' with your instance's domain wherever it appears
ServerName pleroma.example.com Define servername pleroma.example.com
ServerName ${servername}
ServerTokens Prod ServerTokens Prod
ErrorLog ${APACHE_LOG_DIR}/error.log ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined CustomLog ${APACHE_LOG_DIR}/access.log combined
<VirtualHost *:80> <VirtualHost *:80>
Redirect permanent / https://pleroma.example.com Redirect permanent / https://${servername}
</VirtualHost> </VirtualHost>
<VirtualHost *:443> <VirtualHost *:443>
SSLEngine on SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/pleroma.example.com/cert.pem SSLCertificateFile /etc/letsencrypt/live/${servername}/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/pleroma.example.com/privkey.pem SSLCertificateKeyFile /etc/letsencrypt/live/${servername}/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/pleroma.example.com/fullchain.pem SSLCertificateChainFile /etc/letsencrypt/live/${servername}/fullchain.pem
# Mozilla modern configuration, tweak to your needs # Mozilla modern configuration, tweak to your needs
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1 SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
@ -31,7 +33,7 @@ CustomLog ${APACHE_LOG_DIR}/access.log combined
Header always set X-Frame-Options "DENY" Header always set X-Frame-Options "DENY"
Header always set X-Content-Type-Options "nosniff" Header always set X-Content-Type-Options "nosniff"
Header always set Referrer-Policy same-origin Header always set Referrer-Policy same-origin
Header always set Content-Security-Policy "default-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; img-src 'self' data: https:; media-src 'self' https:; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self'; connect-src 'self' wss://pleroma.example.tld; upgrade-insecure-requests;" Header always set Content-Security-Policy "default-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; img-src 'self' data: https:; media-src 'self' https:; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self'; connect-src 'self' wss://${servername}; upgrade-insecure-requests;"
# Uncomment this only after you get HTTPS working. # Uncomment this only after you get HTTPS working.
# Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains" # Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
@ -45,7 +47,7 @@ CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPass / http://localhost:4000/ ProxyPass / http://localhost:4000/
ProxyPassReverse / http://localhost:4000/ ProxyPassReverse / http://localhost:4000/
RequestHeader set Host "pleroma.example.com" RequestHeader set Host ${servername}
ProxyPreserveHost On ProxyPreserveHost On
</VirtualHost> </VirtualHost>

View File

@ -31,9 +31,9 @@ server {
listen 443 ssl http2; listen 443 ssl http2;
ssl_session_timeout 5m; ssl_session_timeout 5m;
ssl_trusted_certificate /etc/letsencrypt/live/example.tld/fullchain.pem; ssl_trusted_certificate /etc/letsencrypt/live/$server_name/fullchain.pem;
ssl_certificate /etc/letsencrypt/live/example.tld/fullchain.pem; ssl_certificate /etc/letsencrypt/live/$server_name/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.tld/privkey.pem; ssl_certificate_key /etc/letsencrypt/live/$server_name/privkey.pem;
# Add TLSv1.0 to support older devices # Add TLSv1.0 to support older devices
ssl_protocols TLSv1.2; ssl_protocols TLSv1.2;
@ -77,7 +77,7 @@ server {
add_header X-Content-Type-Options "nosniff" always; add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "same-origin" always; add_header Referrer-Policy "same-origin" always;
add_header X-Download-Options "noopen" always; add_header X-Download-Options "noopen" always;
add_header Content-Security-Policy "default-src 'none'; base-uri 'self'; form-action *; frame-ancestors 'none'; img-src 'self' data: https:; media-src 'self' https:; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self'; connect-src 'self' wss://example.tld; upgrade-insecure-requests;" always; add_header Content-Security-Policy "default-src 'none'; base-uri 'self'; form-action *; frame-ancestors 'none'; img-src 'self' data: https:; media-src 'self' https:; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self'; connect-src 'self' wss://$server_name; upgrade-insecure-requests;" always;
# Uncomment this only after you get HTTPS working. # Uncomment this only after you get HTTPS working.
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; # add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;