This current configuration is so close to working. The only issue is, it is serving my php files as static files (instead of handing them off to apache2, running on port 81)
I know it is something wrong with this line here location ~ .+(?<!\.php)
. Do I have the negative lookahead syntax wrong?
server {
listen 80;
listen [::]:80;
root /var/www/example.com;
index index.php;
server_name example.com;
location ~ .+(?<!\.php) {
try_files $uri $uri @php;
}
location @php {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:81;
proxy_redirect http://127.0.0.1:81/ /;
proxy_read_timeout 60s;
}
location ~ /\.ht {
deny all;
}
}