I have set Nginx as a reverse proxy according to this tutorial -> [HOW-TO] Use Nginx as a reverse proxy for DirectAdmin which work fine. Then, I started to use Nginx to serve static files for one vhost which is running Drupal. PHP scripts still send to Apache to process through PHP-FPM. Everything seems to work fine until I found that there is one problem. The problem of images which is process by ImageCache. When I upload image, it doesn't shows as it should be.
I have searched around how to prevent hotlink in Drupal when use with Nginx. A lot of website saying the same what to do. However, I have tried all of them but not even one of them that work. That was strange. I started to try more until this... I found the only method that work for me. Oh... one more thing... don't put them under "location" rule or it won't work. That took me half an hour to figure it out :(
Nginx Vhost configuration file - working config to protect hotlink
When you do a reverse proxy in which Nginx will be the one who listen the traffic and forward anything needs to be process through PHP to Apache. With this, Apache will always receive an IP from Nginx server (or I should say localhost / 127.0.0.1 / local IP), not the real IP that user uses. In order to let Apache knows what is real user IP, we need to install mod_rpaf.
Just copy and paste code below into SSH :
I try to use Nginx as a reverse proxy to see if there is any improvement over Apache Worker MPM or not. I found an instruction from DirectAdmin webboard but it's quite old. So, I just tried to follow their steps and do some modification to match what I have read. Below is what I did
1. You need to compile Nginx. Nginx version 0.8.54 is the lastest stable release as of today. So, just copy and paste below code into your SSH