WebFaction
Community site: login faq

I am trying to replicate the way WF handle wordpress installs on my own server: nginx front end an apache2 vhost running wordpress at the back, and route only a sub directory link to the wordpress instance, without success. Anyone know how to do this?

e.g.: mysite.com -> some other apache vhost mysite.com/blog -> a apache vhost running wordpress at the "root directory"

webfaction magically remove the "/blog/" to and from the vhost. I can't get that to work with my own config?

(Why am I doing this? I need to setup a virtual server running something similar to my other webfaction apps on the shared plans).

Thanks! P.K.

asked 27 Oct '10, 10:37

pkshiu's gravatar image

pkshiu
1112
accept rate: 0%


Here's what out configuration looks like to serve an app named 'wp3' for 'username' on 'domain.com/blog':

Front-end nginx:

server {
    listen       174.121.79.152:80;
    server_tokens off;

    proxy_set_header  Host             $host;
    proxy_set_header  X-Forwarded-For  $remote_addr;

    server_name  domain.com;

    location /blog/ {
        proxy_pass  http://localhost:2480;
    }

    location = /blog {
        proxy_pass  http://localhost:2480;
    }

    access_log  /home/username/logs/frontend/access_wpsite.log combined;
    error_log   /home/username/logs/frontend/error_wpsite.log info;
}

Back-end Apache on port 2480:

<VirtualHost 127.0.0.1:2480>
  BrowserMatch "^gnome-vfs" redirect-carefully
  BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
  SuexecUserGroup username username
  ServerName domain.com
  AddHandler cgi-script .cgi .py
  AddOutputFilter INCLUDES .shtml
  AddType text/html .shtml
  DirectoryIndex index.html index.htm index.cgi index.py index.php index.spy nph-index.cgi index.shtml
  DocumentRoot /home/username/webapps/_
  ProxyPreserveHost on
  RewriteEngine on

  <Directory /home/username>
    AllowOverride all
  </Directory>

  Alias /cgi-bin/php52.cgi /home/php-cgi/php52.cgi
  Alias /cgi-bin/php52.fcgi /home/php-cgi/php52.fcgi
  Alias /cgi-bin/php52-fcgi1.fcgi /home/php-cgi/php52.fcgi
  Alias /cgi-bin/php52-fcgi2.fcgi /home/php-cgi/php52-fcgi2.fcgi
  Alias /cgi-bin/php52-fcgi3.fcgi /home/php-cgi/php52-fcgi3.fcgi
  Alias /cgi-bin/php52-fcgi4.fcgi /home/php-cgi/php52-fcgi4.fcgi
  Alias /cgi-bin/php52-fcgi5.fcgi /home/php-cgi/php52-fcgi5.fcgi
  Alias /cgi-bin/php52-fcgi6.fcgi /home/php-cgi/php52-fcgi6.fcgi
  AddHandler php52-cgi .php
  AddHandler fastcgi-script .fcgi
  Action php52-cgi /cgi-bin/php52.cgi
  Action php52-fcgi /cgi-bin/php52.fcgi
  Action php52-fcgi1 /cgi-bin/php52-fcgi1.fcgi
  Action php52-fcgi2 /cgi-bin/php52-fcgi2.fcgi
  Action php52-fcgi3 /cgi-bin/php52-fcgi3.fcgi
  Action php52-fcgi4 /cgi-bin/php52-fcgi4.fcgi
  Action php52-fcgi5 /cgi-bin/php52-fcgi5.fcgi
  Action php52-fcgi6 /cgi-bin/php52-fcgi6.fcgi

  <Location "/cgi-bin/php.fcgi">
     Order Deny,Allow
     Deny from All  
     Allow from env=REDIRECT_STATUS
     Options ExecCGI
     SetHandler fastcgi-script
  </Location>

  <Location "/php.ini">
     Deny from All
  </Location>

  SetEnvIf Request_URI /blog PHP_INI_SCAN_DIR=/home/username/webapps/wp3
  Alias /blog /home/username/webapps/wp3/
  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  LogFormat "%t %a %D %I %O %s %{Content-Type}o %{Host}i \"%r\" \"%{Referer}i\"" host
  CustomLog /home/username/logs/frontend/access_wpsite_php.log combined
  Errorlog /home/username/logs/frontend/error_wpsite_php.log
</VirtualHost>

Hope that helps!

permanent link

answered 27 Oct '10, 11:00

seanf's gravatar image

seanf ♦♦
11.8k21333
accept rate: 37%

edited 27 Oct '10, 11:01

Sean, This is brilliant! I was attaching it from the wrong side trying to get nginx do the rewriting. Using "Alias" to map the sub directory was the "magic" that I was missing. Thank you so much !

P.K.

(27 Oct '10, 11:32) pkshiu pkshiu's gravatar image

You're very welcome! :)

(27 Oct '10, 11:52) seanf ♦♦ seanf's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×237
×183
×8

question asked: 27 Oct '10, 10:37

question was seen: 6,117 times

last updated: 27 Oct '10, 11:52

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM