I'm trying to use an existing nginx running on port 80, to proxypass towards Apache serving a Wordpress website.

nginx section added (some commented tests left intentionally, i tried so many versions sorry if it looks wrong):

upstream wordpress {

server {
    server_name media.raw-news.net;
    access_log /home/plumi/PLUMI/plumi.app/var/log/wordpress-access.log;
    error_log /home/plumi/PLUMI/plumi.app/var/log/wordpress-error.log;

    #root /usr/local/apache2/htdocs/;

    location / {
        proxy_redirect off;
        proxy_pass http://wordpress;
        proxy_connect_timeout 75;
        proxy_read_timeout 185;

 location ~ .*\\.(php)$ {

  proxy_pass         http://wordpress;
  proxy_redirect     off;

  proxy_set_header   Host             $host;
  proxy_set_header   X-Real-IP        $remote_addr;
  proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

  client_max_body_size       10m;
  client_body_buffer_size    128k;

  proxy_connect_timeout      90;
  proxy_send_timeout         90;
  proxy_read_timeout         90;

  proxy_buffer_size          4k;
  proxy_buffers              4 32k;
  proxy_busy_buffers_size    64k;
  proxy_temp_file_write_size 64k;


My Apache is running on port 5000 with PHP enabled (only relevant php stuff):

LoadModule php5_module        modules/libphp5.so

<IfModule dir_module>
    DirectoryIndex index.php index.html

AddType text/html .php
AddHandler php5-script  .php

The effect right now is that:

Chrome: the Wordpress website is shown, but looks like no PHP code is executed.. i can only see the HTML part.

Firefox: browsing the Wordpress site causes redirect on ...

Safari: It Works ! is displayed...

Strangely, on all browsers if i browse http://media.example.net/wp-admin and perform login.. i can enter the Dashboard and everything is displayed perfectly !

All images are there, PHP code gets executed... but only after logging in the Dashboard !

What am i missing here ?

I did not create any VirtualHost in Apache, it is a simple Apache 2.4 server with the Wordpress site inside the default DocumentRoot.

I cannot migrate on newer nginx version cause its running a Production website.

Migration is already planned when Plumi will officially release the 4.5.2 on Debian 8.

Is there any preferred/working configuration to properly proxypass all the Wordpress content to my Apache without having it to redirect to for example, and properly executing PHP Code on Apache ?

Thanks !

  • If all the data is being sent to Apache's backend, why do you have to separate location blocks? That only serves to do configuration code duplication... – Thomas Ward Oct 8 '15 at 13:16

You may wish to set (and use) additional headers for proxying to the Apache instance, such as these:

proxy_set_header    X-Real-IP         $remote_addr;
proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;

Most backends (including Apache and PHP) will work with one or more of these, as well as $Host (so it knows what site's being requested).

This should then allow for Apache's PHP to recognize the additional data and essentially say "Oh, this did NOT originate from localhost, it's actual origin is from $remote_addr". ($remote_addr is a variable that indicates the real IP address of the real source, and the X-Forwarded-For works similarly.)

  • thanks for replying. Question edited as you are suggesting. You may also browse media.rawnews.net and check the actual mess i'm into.. uncommenting the "root" only causes nginx to process and log some css/js. I'd like to have everything processed by Apache, but its not happening. – KRiSh05 Oct 8 '15 at 13:35
  • @KRiSh05: edit your own question and add this data. Also indicate in your question what you have tried - you didn't state that you tried these, therefore I could not have known. Also, copy-pasting configs in won't help you in comments - edit your question to add such data instead. – Thomas Ward Oct 8 '15 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.