1+ #ddev-generated
2+ # ddev wordpress config with Kanopi proxy support
3+ # https://developer.wordpress.org/advanced-administration/server/web-server/nginx/
4+
5+ # Much of this config is adapted from
6+ # https://codex.wordpress.org/Nginx
7+
8+ server {
9+ listen 80 default_server;
10+ listen 443 ssl default_server;
11+
12+ root /var/www/html/public;
13+
14+ ssl_certificate /etc/ssl/certs/master.crt;
15+ ssl_certificate_key /etc/ssl/certs/master.key;
16+
17+ include /etc/nginx/monitoring.conf;
18+
19+ index index.php index.htm index.html;
20+
21+ # Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
22+ sendfile off;
23+ error_log /dev/stdout info;
24+ access_log /var/log/nginx/access.log;
25+
26+ # From wordpress demo global_restrictions.conf
27+ # Global restrictions configuration file.
28+ # Designed to be included in any server {} block.
29+ location = /favicon.ico {
30+ log_not_found off;
31+ access_log off;
32+ }
33+
34+ location = /robots.txt {
35+ allow all;
36+ log_not_found off;
37+ access_log off;
38+ }
39+
40+ # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
41+ # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
42+ location ~ /\. {
43+ deny all;
44+ }
45+
46+ # Deny access to any files with a .php extension in the uploads directory
47+ # Works in sub-directory installs and also in multisite network
48+ # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
49+ location ~* /(?:uploads|files)/.*\.php$ {
50+ deny all;
51+ }
52+
53+ # Image proxy configuration for wp-content/uploads
54+ location ~ ^/wp-content/uploads/.* {
55+ try_files $uri @proxy;
56+ }
57+
58+ location @proxy {
59+ # Proxy missing uploads to hosting provider environment
60+ resolver 8.8.8.8;
61+ proxy_pass PROXY_URL_PLACEHOLDER$request_uri;
62+ proxy_set_header Host HOST_PLACEHOLDER;
63+ proxy_set_header X-Real-IP $remote_addr;
64+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
65+ proxy_set_header X-Forwarded-Proto $scheme;
66+ proxy_ssl_verify off;
67+ proxy_intercept_errors on;
68+ }
69+
70+ location / {
71+ absolute_redirect off;
72+ # This is cool because no php is touched for static content.
73+ # include the "?$args" part so non-default permalinks doesn't break when using query string
74+ try_files $uri $uri/ /index.php?$args;
75+ }
76+
77+ # pass the PHP scripts to FastCGI server listening on socket
78+ location ~ \.php$ {
79+ try_files $uri =404;
80+ fastcgi_split_path_info ^(.+\.php)(/.+)$;
81+ fastcgi_pass unix:/run/php-fpm.sock;
82+ fastcgi_buffers 16 16k;
83+ fastcgi_buffer_size 32k;
84+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
85+ fastcgi_param SCRIPT_NAME $fastcgi_script_name;
86+ fastcgi_index index.php;
87+ include fastcgi_params;
88+ fastcgi_intercept_errors off;
89+ # fastcgi_read_timeout should match max_execution_time in php.ini
90+ fastcgi_read_timeout 10m;
91+ fastcgi_param SERVER_NAME $host;
92+ fastcgi_param HTTPS $fcgi_https;
93+ # Pass the X-Accel-* headers to facilitate testing.
94+ fastcgi_pass_header "X-Accel-Buffering";
95+ fastcgi_pass_header "X-Accel-Charset";
96+ fastcgi_pass_header "X-Accel-Expires";
97+ fastcgi_pass_header "X-Accel-Limit-Rate";
98+ fastcgi_pass_header "X-Accel-Redirect";
99+ }
100+
101+ # Expire rules for static content
102+
103+ # Media: images, icons, video, audio, HTC (exclude wp-content/uploads which has proxy)
104+ location ~* ^(?!/wp-content/uploads).*\.(jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|webp|htc)$ {
105+ expires max;
106+ log_not_found off;
107+ try_files $uri /index.php$is_args$args;
108+ }
109+ location ~* \.(js|css)$ {
110+ expires -1;
111+ log_not_found off;
112+ }
113+ include /etc/nginx/common.d/*.conf;
114+ include /mnt/ddev_config/nginx/*.conf;
115+ }
0 commit comments