<commit_before><?xml version="1.0" encoding="utf-8"?>
<!-- $Id$ -->
<book>
    <bookinfo>
        <graphic fileref="logo.jpg"/>
        <productname>Open Source Native XML Database</productname>
        <title>Proxying eXist behind a Web Server</title>
        <orgname>The eXist Project</orgname>
        <date>September 2009</date>
        <author>
            <firstname>Adam</firstname>
            <surname>Retter</surname>
        </author>
    </bookinfo>
    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sidebar.xml"/>
    <chapter>
        <title>Production use - Proxying eXist behind a Web Server</title>
        <abstract>
            <para>From a security perspective, it is recognised best practice to proxy Web Application Servers behind dedicated Web Servers, and eXist is no exception.</para>
            <para>Some other nice side-effects of proxying eXist behind a Web Server include -</para>
            <variablelist>
                <varlistentry>
                    <term>Unified web namespace</term>
                    <listitem>
                        <para>You can map eXist or an application build atop eXist into an existing web namespace. If your website is - http://www.mywebsite.com, then your eXist application could be mapped into http://www.mywebsite.com/myapplication/.</para>
                    </listitem>
                </varlistentry>
                <varlistentry>
                    <term>Virtual Hosting</term>
                    <listitem>Providing your Web Server supports Virtual Hosting, then you should be able to proxy many URLs from different domains onto different eXist REST URLs which may belong to one or more eXist instances. This in effect allows a single eXist instance to perform virtual hosting.</listitem>
                </varlistentry>
            </variablelist>
            <para>Examples are provided for -</para>
            <variablelist>
                <varlistentry>
                    <term><ulink url="http://wiki.nginx.org/Main">Nginx</ulink></term>
                    <listitem>
                        <para>A very small but extremely poweful Web Server which is also very simple to configure. It powers some of the biggest sites on the Web.</para>
                    </listitem>
                </varlistentry>
                <varlistentry>
                    <term><ulink url="http://httpd.apache.org/">Apache HTTPD</ulink></term>
                    <listitem>The most prolific Web Server used on the web.</listitem>
                </varlistentry>
                
            </variablelist>
        </abstract>
        <section>
            <title>Example 1 - Proxying a Web Domain Name to an eXist Collection</title>
            <para>In this example we look at how to proxy a web domain name onto an eXist Collection. We make the following assumptions -</para>
            <orderedlist>
                <listitem>http://www.mywebsite.com is our website domain name address</listitem>
                <listitem>eXist is running in standalone mode (i.e. http://localhost:8088/) on the same host as the Web Server (i.e. http://localhost:80/)</listitem>
                <listitem>/db/mywebsite.com is the eXist collection we want to proxy</listitem>
                <listitem>Web Server access logging will be written to /srv/www/vhosts/mywebsite.com/logs/access.log</listitem>
            </orderedlist>
            <section>
                <title>Nginx</title>
                <para>This needs to be added to the http section of the nginx.conf file -</para>
                <programlisting language="nginx">
server {
    listen 80;
    server_name *.mywebsite.com;
    charset utf-8;
    access_log /srv/www/vhosts/mywebsite.com/logs/access.log;

    location / {
        proxy_pass http://localhost:8088/db/mywebsite.com/;
    }
}
                </programlisting>
            </section>
            <!-- section>
                <title>Apache HTTPD</title>
                <para></para>
            </section -->
        </section>
    </chapter>
</book><commit_msg>Further updates for Reverse proxying with nginx and eXist-db<commit_after><?xml version="1.0" encoding="utf-8"?>
<!-- $Id$ -->
<book>
    <bookinfo>
        <graphic fileref="logo.jpg"/>
        <productname>Open Source Native XML Database</productname>
        <title>Proxying eXist behind a Web Server</title>
        <orgname>The eXist Project</orgname>
        <date>September 2009</date>
        <author>
            <firstname>Adam</firstname>
            <surname>Retter</surname>
        </author>
    </bookinfo>
    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sidebar.xml"/>
    <chapter>
        <title>Production use - Proxying eXist behind a Web Server</title>
        <abstract>
            <para>From a security perspective, it is recognised best practice to proxy Web Application Servers behind dedicated Web Servers, and eXist is no exception.</para>
            <para>Some other nice side-effects of proxying eXist behind a Web Server include -</para>
            <variablelist>
                <varlistentry>
                    <term>Unified web namespace</term>
                    <listitem>
                        <para>You can map eXist or an application build atop eXist into an existing web namespace. If your website is - http://www.mywebsite.com, then your eXist application could be mapped into http://www.mywebsite.com/myapplication/.</para>
                    </listitem>
                </varlistentry>
                <varlistentry>
                    <term>Virtual Hosting</term>
                    <listitem>Providing your Web Server supports Virtual Hosting, then you should be able to proxy many URLs from different domains onto different eXist REST URLs which may belong to one or more eXist instances. This in effect allows a single eXist instance to perform virtual hosting.</listitem>
                </varlistentry>
            </variablelist>
            <para>Examples are provided for -</para>
            <variablelist>
                <varlistentry>
                    <term><ulink url="http://wiki.nginx.org/Main">Nginx</ulink></term>
                    <listitem>
                        <para>A very small but extremely poweful Web Server which is also very simple to configure. It powers some of the biggest sites on the Web.</para>
                    </listitem>
                </varlistentry>
                <varlistentry>
                    <term><ulink url="http://httpd.apache.org/">Apache HTTPD</ulink></term>
                    <listitem>The most prolific Web Server used on the web.</listitem>
                </varlistentry>
                
            </variablelist>
        </abstract>
        <section>
            <title>Example 1 - Proxying a Web Domain Name to an eXist Collection</title>
            <para>In this example we look at how to proxy a web domain name onto an eXist Collection. We make the following assumptions -</para>
            <orderedlist>
                <listitem>http://www.mywebsite.com is our website domain name address</listitem>
                <listitem>eXist is running in standalone mode (i.e. http://localhost:8088/) on the same host as the Web Server (i.e. http://localhost:80/)</listitem>
                <listitem>/db/mywebsite.com is the eXist collection we want to proxy</listitem>
                <listitem>Web Server access logging will be written to /srv/www/vhosts/mywebsite.com/logs/access.log</listitem>
            </orderedlist>
            <section>
                <title>Nginx</title>
                <para>This needs to be added to the http section of the nginx.conf file -</para>
                <programlisting language="nginx">


# header helpers for reverse proxied servers
proxy_set_header        Host                    $host;                          # Ensures the actual hostname is sent to eXist-db and not 'localhost'
proxy_set_header        X-Real-IP               $remote_addr;                   # The Real IP of the client and not the IP of nginx proxy
proxy_set_header        X-Forwarded-For         $proxy_add_x_forwarded_for;
proxy_set_header        nginx-request-uri       $request_uri;                   # The original URI before proxying

# virtual host configuration, reverse proxy to eXist-db
server {
    listen 80;
    server_name *.mywebsite.com;
    charset utf-8;
    access_log /srv/www/vhosts/mywebsite.com/logs/access.log;

    location / {
        proxy_pass http://localhost:8088/db/mywebsite.com/;
    }
}
                </programlisting>
            </section>
            <!-- section>
                <title>Apache HTTPD</title>
                <para></para>
            </section -->
        </section>
    </chapter>
</book>
{'fraction_non_alphanumeric': 0.09710837887067396, 'fraction_numerical': 0.005919854280510018, 'mean_word_length': 1.9050925925925926, 'pattern_counts': {'":': 0, '<': 203, '<?xml version=': 2, '>': 203, 'https://': 0, 'lorem ipsum': 0, 'www.': 12, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3933693', 'n_tokens_mistral': 2451, 'n_tokens_neox': 2270, 'n_words': 737}