Skip to content

Instantly share code, notes, and snippets.

@tlacroix
Last active July 9, 2020 12:46
Show Gist options
  • Save tlacroix/bf771ff2829a1dc279a014a2763e8477 to your computer and use it in GitHub Desktop.
Save tlacroix/bf771ff2829a1dc279a014a2763e8477 to your computer and use it in GitHub Desktop.
Basic WordPress configuration for nginx
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_processes auto;
worker_connections 1024; # ulimit -n
multi_accept on;
use epoll;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
fastcgi_read_timeout 1h;
server_tokens off;
server_names_hash_bucket_size 128;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 10m;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log crit;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types
# text/html is always compressed by HttpGzipModule
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
application/atom+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
server {
listen 80 defaultserver;
#listen [::]:80 ipv6only=on;
#listen 443 ssl http2;
#listen [::] ssl http2 ipv6only=on;
#ssl_certificate /var/www/pnp-api/etc/ssl/certs/example.com.crt;
#ssl_certificate_key /var/www/pnp-api/etc/ssl/private/example.com.key;
#ssl_ciphers HIGH:!aNULL:!MD5;
#ssl_protocols TLSv1.2 TLSv1.3;
#ssl_session_cache shared:SSL:20m;
#ssl_session_timeout 10m;
access_log /var/log/nginx/example.com-access.log;
error_log /var/log/nginx/example.com-error.log;
root /var/www/html;
index index.php index.html index.htm;
server_name your_domain.com;
location / {
send_timeout 300s;
client_max_body_size 1024m;
client_body_timeout 600s;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
#error_page 404 /404.html;
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
#root /usr/share/nginx/html;
#}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php7.3-fpm.sock;
fastcgi_index index.php;
fastcgi_keep_conn on;
fastcgi_hide_header "X-Powered-By";
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
reset_timedout_connection on;
client_body_timeout 10;
send_timeout 2;
keepalive_timeout 30;
keepalive_requests 100000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment