title: Wordpress along side Node using Nginx and Apache
body: <p>I'm trying to host a wordpress on /blog. I use Nginx as proxy and Apache to run Wordpress. I think I'm very close to a working solution.</p>
  
  <p>The only problem I'm facing now is going to /blog/wp-admin loads the wordpress dashboard but then something is rewriting or redirecting to /wp-admin. The frontend pages are ok, e.g.: /blog/2015/05/28/hello-world/.</p>
  
  <p>How can I figure out who is rewriting the dashboard url from <strong>www.example.com/blog/wp-admin</strong> into <strong>www.example.com/wp-admin/</strong> ?</p>
  
  <p>This is my Nginx config:</p>
  
  <pre><code>upstream app_node {
      server 127.0.0.1:3000;
  }
  
  upstream app_wordpress {
      server 127.0.0.1:8080;
  }
  
  server {
    listen 0.0.0.0:80;
    server_name example.com;
    access_log /var/log/nginx/node.log;
    error_log /var/log/nginx/node.error.log debug;
    #port_in_redirect off;
    rewrite_log on;
  
    client_max_body_size 50M;
  
  # pass the request to the node.js server with the correct headers
  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
  
    proxy_pass http://app_node/;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
  location ~ ^\/blog(.*)$ {
  
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header Host $host;
      proxy_pass http://127.0.0.1:8080$1;
      proxy_redirect off;
  }
  </code></pre>
  
  <p>Apache config:</p>
  
  <pre><code>&lt;VirtualHost *:8080&gt;
         ServerName example.com:8080
  
          ServerAdmin webmaster@localhost
          DocumentRoot /var/www/html
          &lt;Directory /var/www/html/&gt;
                  AllowOverride All
          &lt;/Directory&gt;
  
          ErrorLog ${APACHE_LOG_DIR}/error.log
          CustomLog ${APACHE_LOG_DIR}/access.log combined
  
          LogLevel alert rewrite:trace6
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Wordpress htaccess (wordpress files are in /var/www/html):</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  &lt;/IfModule&gt;
  </code></pre>