By dciphered
Referencing article:
Thanks for the write-up, it was (for the most part) successful however I’ve gotten to a problematic point and cannot find a solution.
In step 11 describing the setup of static caching, the location directives change. Now, when my server config only uses the following location directive, proxying to Apache works well:
location / {
proxy_pass http://your_server_ip:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
However, the moment I change the location directive to "location ~ \.php$ {", nothing works. The website attempts to load but it’s mostly broken.
I’ve tried numerous iterations of the config you’ve described in step 11 but nothing works, unless I change the location directive back to "location / {".
I’m trying to setup FastCGI caching in reverse proxy mode but so far have hit a major brick-wall based on parsing of the config file.
Would really appreciate some help with this.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
If you are proxying the connection to a PHP-FPM backend directly without going through Apache, it is not enough to only update "location ~ \.php$ {" part but you also need to change the proxy rules. Uou could use the following configuration:
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
Note that you need to change the 7.4 with your actual PHP version.
For setting up Nginx with PHP-FPM I could suggest this tutorial here:
Let me know how it goes. Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
