Created
March 16, 2021 05:25
-
-
Save jasperf/8c05c34bac9c482f12dc8a23bebd5cb7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
limit_req_zone $http_x_forwarded_for zone=three:20m rate=10r/s; | |
server { | |
server_name www.domain.com domain.com; | |
root /var/www/domain.com/htdocs; | |
index index.php; | |
access_log /var/log/nginx/domain.com.access.log; | |
error_log /var/log/nginx/domain.com.error.log; | |
client_max_body_size 100M; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ .php$ { | |
try_files $uri =404; | |
include fastcgi_params; | |
# substitute the socket, or address and port, of your WordPress server | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | |
#fastcgi_pass 127.0.0.1:9000; | |
} | |
location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { | |
expires max; | |
log_not_found off; | |
access_log off; | |
} | |
# Deny access to uploads that aren’t images, videos, music, etc. | |
location ~* ^/wp-content/uploads/.*.(html|htm|shtml|php|js|swf)$ { | |
deny all; | |
} | |
# Deny public access to wp-config.php | |
location ~* wp-config.php { | |
deny all; | |
} | |
# Deny access to wp-login.php | |
#location = /wp-login.php { | |
# limit_req zone=three nodelay; | |
# fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | |
#} | |
# Expire rules for static content | |
# Media: images, icons, video, audio, HTC | |
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { | |
expires 1M; | |
access_log off; | |
add_header Cache-Control "public"; | |
} | |
# CSS and Javascript | |
location ~* \.(?:css|js)$ { | |
expires 1y; | |
access_log off; | |
add_header Cache-Control "public"; | |
} | |
# Rocket-Nginx configuration | |
# include rocket-nginx/default.conf; | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/domain.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 { | |
if ($host = www.domain.com) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
if ($host = domain.com) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
server_name www.domain.com domain.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