Last active
December 12, 2019 19:15
-
-
Save bayupermadi/e61abb7bea23b84259556db6db589675 to your computer and use it in GitHub Desktop.
Nginx configuration template for wordpress
This file contains 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
# Redirect HTTP -> HTTPS | |
server { | |
listen 80; | |
server_name www.your-domain.com your-domain.com; | |
return 301 https://your-domain.com$request_uri; | |
} | |
server { | |
listen 443 ssl http2; | |
server_name your-domain.com; | |
root /var/www/html/your-domain.com; | |
index index.php; | |
# SSL parameters | |
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem; | |
ssl_trusted_certificate /etc/letsencrypt/live/your-domain.com/chain.pem; | |
# log files | |
access_log /var/log/nginx/your-domain.com.access.log; | |
error_log /var/log/nginx/your-domain.com.error.log; | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_pass unix:/run/php-fpm/www.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { | |
expires max; | |
log_not_found off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment