Skip to content

Instantly share code, notes, and snippets.

@LeonAlvarez
Last active June 29, 2019 15:50
Show Gist options
  • Save LeonAlvarez/72a7935a943ff1e62dcf738356741781 to your computer and use it in GitHub Desktop.
Save LeonAlvarez/72a7935a943ff1e62dcf738356741781 to your computer and use it in GitHub Desktop.
nignx conf\
---
---
server {
listen <%= ipV4 ? `*${ipV4}` : '' %>:443 ssl http2;
listen [::<%= ipV6 || '' %>:]:443 ssl http2;
server_name <%= domain %>;
set $base /var/www/<%= domain %>;
root $base/public;
# SSL
ssl_certificate /etc/letsencrypt/live/<%= domain %>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<%= domain %>/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/<%= domain %>/chain.pem;
# security
include /etc/nginx/conf/security.conf;
# index.php
index index.php;
# index.php fallback
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# handle .php
location ~ \.php$ {
include /etc/nginx/conf/php_fastcgi.conf;
}
# additional config
include /etc/nginx/conf/general.conf;
}
# subdomains redirect
server {
listen <%= ipV4 ? `*${ipV4}` : '' %>:443 ssl http2;
listen [::<%= ipV6 || '' %>:]:443 ssl http2;
server_name *.<%= domain %>;
# SSL
ssl_certificate /etc/letsencrypt/live/<%= domain %>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<%= domain %>/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/<%= domain %>/chain.pem;
return 301 https://<%= domain %>$request_uri;
}
# HTTP redirect
server {
listen <%= ipV4 ? `*${ipV4}` : '' %>:80;
listen [::<%= ipV6 || '' %>:]:80;
server_name .<%= domain %>;
include /etc/nginx/conf/letsencrypt.conf;
location / {
return 301 https://<%= domain %>$request_uri;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment