WebFaction
Community site: login faq

Diazo is a proxy server able to re-theme any existing website, local or distant. More info on diazo.org.

Nginx is a light-weight webserver that can serve this proxy content. In order to do so, Nginx needs a specific module that is not yet incoprporated in the server.

Another avenue I did not explore was using Apache and WSGI. That might have been easier.

Well, anyway, here is what I needed to do in order to get Nginx working for Webfaction.

Compile Nginx for Diazo

Download Nginx source code from here: http://nginx.org/en/download.html I used the following source code here: http://nginx.org/download/nginx-1.6.1.zip I unzipped the source code and opened a console to that source-code directory.

Then I applied the following patch for Diazo to work https://github.com/jcu-eresearch/nginx-custom-build/blob/master/nginx-xslt-html-parser.patch With this command

patch src/http/modules/ngx_http_xslt_filter_module.c nginx-xslt-html-parser.patch

Then I installed the Nginx accept language module: https://github.com/giom/nginx_accept_language_module That is hosted here: https://github.com/giom/nginx_accept_language_module from the following download link: https://github.com/giom/nginx_accept_language_module/archive/master.zip that I unzipped into a different directory, /home/username/hacks/nginx_accept_language_module-master

I used the following line to compile Nginx 1.6 with the patch on Webfaction

./configure --with-http_xslt_module --with-http_stub_status_module --add-module=/home/username/hacks/nginx_accept_language_module-master --with-ipv6 --with-http_ssl_module --with-cc-opt=-Wno-error --prefix=/home/username/opt/nginxslt

After the configuration, and creating the installation directory, I did a make and then a make install. The Nginx executable is now in /home/username/nginxslt/sbin/nginx.

Setting Up a Diazo Development Environment on my Windows Machine

Directions for setting up a Diazo development environment are available here: http://docs.diazo.org/en/latest/installation.html

I choose the easy_install methode. First, I installed Python 2 for Windows from here: https://www.python.org/downloads/ or more specificly in my case https://www.python.org/ftp/python/2.7.8/python-2.7.8.msi specifying that I wanted to use the d:\opt\python2 as my installation directory. The installation did not change my environmental variables, and I had to add d:\opt\python2\bin;d:\opt\python2\Scripts to the %PATH% variable manually.

After installation and variable modification, I think I executed easy_install -U diazo without a hitch. For some reason, I was unable to install Diazo on Webfaction.

Compiling of a template Diazo is as follows: diazocompiller -o theme.xsl -r rules.xml where the theme.html files are relative to the compiling directory of rules.xml.

Configuration of Diazo on Webfaction

I am going to be lazy and just show parts of the nginx.conf file from /home/username/nginxslt/conf/nginx.conf.

Global variables

# in http { context
# Augmented head size allocations
proxy_headers_hash_bucket_size 128;
proxy_headers_hash_max_size 1024;


# Set up a map for available languages for the websites
map $http_accept_language $lang {
    default en;
    ~fr fr;
}

The main server was just putting a theme around XHTML content in a folder.

# in http { context
server {
    listen       30742;
    server_name  example.com www.example.com;
    server_name_in_redirect on; # Not sure if this part is necessary
    location / {
        xslt_stylesheet /home/username/webapps/diazoman/theme.xsl
            path='$uri'
            ;
        xslt_html_parser on;
        xslt_types text/html;
        # rewrite / $1/$lang;
        rewrite ^/?$ $scheme://$host/$lang/;
        #rewrite ^/raw(.*)$ $1;
        root   /home/username/webapps/diazoman/html;
        index  index.html index.htm;
    }
    location /blog {
        xslt_stylesheet /home/username/webapps/diazoman/theme.xsl
            path='$uri'
            ;
        xslt_html_parser on;
        xslt_types text/html;
        proxy_headers_hash_max_size 51200;
        proxy_pass http://wordpress.example.com/;
        proxy_set_header Host wordpress.example.com;
        #rewrite ^/blog/(.*)+$ /blog/index.php?$1;
        rewrite ^/blog/(.*)$ /$1 break;
        #proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Diazo "true";
        proxy_set_header Accept-Encoding "";
    }

I had some fun theming a friend's server in Chinese.

# In http context
server {
    listen 30742;
    server_name joomla.example.com;
    root /home/username/webapps/diazoman/html;

    location / {
    # rewrite /example/example /example;
    xslt_stylesheet /home/username/webapps/diazoman/theme.xsl
        path='$uri'
        ;
    xslt_html_parser on;
    xslt_types text/html;
    proxy_pass http://landdu.com/;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Diazo "true";
    proxy_set_header Accept-Encoding "";
    }

    location /css/ {}
    location /favicon.ico {}
    location /images/images/ {}
}

Starting / Restarting / Stopping of Diazo on Webfaction

To start: /home/username/opt/nginxslt/sbin/nginx

To stop (as user chris2fr): killall -9 nginx

To restart: killall -9 nginx;/home/username/opt/nginxslt/sbin/nginx

TODO Automatic Start and Stop Scripts on Webfaction

TODO

asked 21 Aug '14, 05:07

chris2fr
123
accept rate: 0%

edited 21 Aug '14, 05:15

Be the first one to answer this question!
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:

×186
×6
×1

question asked: 21 Aug '14, 05:07

question was seen: 2,554 times

last updated: 21 Aug '14, 05:15

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 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