Skip to content

Instantly share code, notes, and snippets.

@marvinhosea
Last active July 4, 2020 10:22
Show Gist options
  • Save marvinhosea/2bf1dac5558113ab12691a107469c4c3 to your computer and use it in GitHub Desktop.
Save marvinhosea/2bf1dac5558113ab12691a107469c4c3 to your computer and use it in GitHub Desktop.
server {
root /project-dir;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name exampledomain.com www.exampledomain.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
# fastcgi_param ACCOUNT $account; # $_SERVER['ACCOUNT']
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/exampledomain.pro/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/exampledomain.pro/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.exampledomain.com) {
return 301 https://marvinhosea.pro$request_uri;
} # managed by Certbot
if ($host = exampledomain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name exampledomain.com www.exampledomain.com;
listen 80;
return 404; # managed by Certbot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment