Apache & Nginx Running Together (Proxy)

Hi All,

I am trying to get Apache and Nginx to work side by side, and have had a little bit of success, in terms of getting PHP files to be handled by Apache and the other static parts handled by Nginx.

I have Apache (httpd) running on port 8080 and Nginx on 80. The idea is to bypass php files by nginx and process them through to apache for processing (so I can keep .htaccess files working).

So far, I have edited:

Under the domain I am testing on i have added:

location / {
try_files $uri $uri/ /index.php;
location ~ .php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;

Then under Server > Apache, I created a new virtual host with the domain name.

Restarted nginx and apache and everything works.

Now my question is, how can I go about changing the way virtual servers are set up to select both nginx and apache web service, so both nginx.conf and httpd.conf gets edited with the correct details? - I would be stick by the time i’ve updated all these details by hand.

Has no one managed to do this?