Skip to content

Instantly share code, notes, and snippets.

@PhongGCS
Created April 23, 2020 08:55
Show Gist options
  • Save PhongGCS/40d7dcd8310c22952d2497a4296982b0 to your computer and use it in GitHub Desktop.
Save PhongGCS/40d7dcd8310c22952d2497a4296982b0 to your computer and use it in GitHub Desktop.
Nginx Vhost Configuration
server {
listen *:80;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/dokhacphong.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/dokhacphong.com/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_name dokhacphong.com www.dokhacphong.com 206.189.38.169;
root /var/www/html/;
gzip on;
if ($scheme != "https") {
rewrite ^ https://$http_host$request_uri? permanent;
}
index index.html index.htm index.php index.cgi index.pl index.xhtml;
error_log /var/log/error.log;
access_log /var/log/access.log combined;
location ~ /\. {
deny all;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ .php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
# fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
}
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js|otf|woff|ttf|woff2|svg)$ {
expires 7d;
}
location ~* \.(pdf)$ {
expires 7d;
}
}
# server {
# if ($host = www.dokhacphong.com) {
# return 301 https://$host$request_uri;
# } # managed by Certbot
# if ($host = dokhacphong.com) {
# return 301 https://$host$request_uri;
# } # managed by Certbot
# server_name dokhacphong.com www.dokhacphong.com 206.189.38.169;
# return 404; # managed by Certbot
#
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment