appserver-io/webserver

View on GitHub
etc/webserver.xml

Summary

Maintainability
Test Coverage
<config>

    <description><![CDATA[This is an example of a php WebServer configuration in xml]]></description>

    <loggers>
        <!-- <logger name="System" type="\AppserverIo\Server\Loggers\DummyLogger"/> -->
        <logger name="System" type="\AppserverIo\Logger\Logger">
            <!-- Example for using processors -->
            <!--
            <processors>
                <processor type="\AppserverIo\Logger\Processors\SysloadProcessor" />
            </processors>
            -->
            <handlers>
                <!-- Default stream handler to log file -->
                <handler type="\AppserverIo\Logger\Handlers\CustomFileHandler">
                    <params>
                        <param name="stream" type="string">var/log/webserver-system.log</param>
                        <param name="level" type="integer">info</param>
                    </params>
                </handler>
                <!-- Example for using a hipchat handler -->
                <!--
                <handler type="\Monolog\Handler\HipChatHandler">
                    <formatter type="\Monolog\Formatter\LineFormatter">
                        <params>
                            <param name="output" type="string"><![CDATA[%channel%.%level_name%: %message%]]></param>
                        </params>
                    </formatter>
                    <params>
                        <param name="token" type="string">YOUR API KEY</param>
                        <param name="room" type="string">WebServer</param>
                        <param name="name" type="string">PhpWebServer</param>
                        <param name="notify" type="boolean">0</param>
                        <param name="level" type="integer">200</param>
                        <param name="bubble" type="boolean">1</param>
                        <param name="useSSL" type="boolean">1</param>
                        <param name="format" type="string">text</param>
                    </params>
                </handler>
                -->
            </handlers>
        </logger>
        <logger name="Access" type="\AppserverIo\Logger\Logger">
            <handlers>
                <handler type="\AppserverIo\Logger\Handlers\CustomFileHandler">
                    <formatter type="\AppserverIo\Logger\Formatters\StandardFormatter">
                        <params>
                            <param name="format" type="string">%4$s</param>
                        </params>
                    </formatter>
                    <params>
                        <param name="stream" type="string">var/log/webserver-access.log</param>
                        <param name="level" type="integer">info</param>
                    </params>
                </handler>
            </handlers>
        </logger>
    </loggers>

    <upstreams>
        <upstream name="backend" type="\AppserverIo\WebServer\Upstreams\DefaultUpstream">
            <servers>
                <server name="local-apache" type="\AppserverIo\WebServer\Upstreams\Servers\DefaultServer">
                    <params>
                        <param name="address" type="string">127.0.0.1</param>
                        <param name="port" type="integer">80</param>
                        <param name="weight" type="integer">1</param>
                        <param name="maxFails" type="integer">10</param>
                        <param name="failTimeout" type="integer">30</param>
                        <param name="maxConns" type="integer">64</param>
                        <param name="backup" type="boolean">false</param>
                        <param name="down" type="boolean">false</param>
                        <param name="resolve" type="boolean">false</param>
                    </params>
                </server>
                <server name="local-nginx" type="\AppserverIo\WebServer\Upstreams\Servers\DefaultServer">
                    <params>
                        <param name="address" type="string">127.0.0.1</param>
                        <param name="port" type="integer">8080</param>
                        <param name="weight" type="integer">1</param>
                        <param name="maxFails" type="integer">10</param>
                        <param name="failTimeout" type="integer">30</param>
                        <param name="maxConns" type="integer">64</param>
                        <param name="backup" type="boolean">false</param>
                        <param name="down" type="boolean">false</param>
                        <param name="resolve" type="boolean">false</param>
                    </params>
                </server>
            </servers>
        </upstream>
    </upstreams>

    <servers>
        <server
            name="httpServer"
            type="\AppserverIo\Server\Servers\MultiThreadedServer"
            worker="\AppserverIo\Server\Workers\ThreadWorker"
            socket="\AppserverIo\Server\Sockets\StreamSocket"
            streamContext="\AppserverIo\Server\Contexts\StreamContext"
            serverContext="\AppserverIo\Server\Contexts\ServerContext"
            requestContext="\AppserverIo\Server\Contexts\RequestContext"
            loggerName="System">
            
            <params>
                <param name="admin" type="string">www@localhost.localdomain</param>
                <param name="software" type="string">phpWebServer/7.0.0</param>
                <param name="transport" type="string">tcp</param>
                <param name="address" type="string">0.0.0.0</param>
                <param name="port" type="integer">9080</param>
                <param name="workerNumber" type="integer">64</param>
                <param name="workerAcceptMin" type="integer">16</param>
                <param name="workerAcceptMax" type="integer">64</param>
                <!-- Note: it's intended to use a relative path to get content from webservers basedir/var/www -->
                <param name="documentRoot" type="string">var/www</param>
                <param name="directoryIndex" type="string">index.php index.html index.htm</param>
                <param name="keepAliveMax" type="integer">64</param>
                <param name="keepAliveTimeout" type="integer">5</param>
                <param name="autoIndex" type="boolean">true</param>
                <param name="errorsPageTemplatePath" type="string">resources/templates/www/error.phtml</param>
                <param name="welcomePageTemplatePath" type="string">resources/templates/www/welcome.phtml</param>
                <param name="autoIndexTemplatePath" type="string">resources/templates/www/auto_index.phtml</param>
            </params>

            <headers>
                <header type="response" name="Server" value="PHP WEBSERVER" override="true"/>
                <header type="response" name="X-Powered-By" value="Me"/>
            </headers>

            <authentications>
                <authentication uri="^\/auth\/basic\/.*">
                    <params>
                        <param name="type" type="string">\AppserverIo\Http\Authentication\BasicAuthentication</param>
                        <param name="realm" type="string">PhpWebServer Basic Authentication System</param>
                        <param name="file" type="string">resources/auth/basic/.htpasswd</param>
                    </params>
                </authentication>
                <authentication uri="^\/auth\/digest\/.*">
                    <params>
                        <param name="type" type="string">\AppserverIo\Http\Authentication\DigestAuthentication</param>
                        <param name="realm" type="string">appserver.io Digest Authentication System</param>
                        <param name="file" type="string">resources/auth/digest/.htpasswd</param>
                    </params>
                </authentication>
            </authentications>

            <accesses>
                <!-- per default allow everything for local address -->
                <access type="allow">
                    <params>
                        <param name="X_REQUEST_URI" type="string">.*</param>
                    </params>
                </access>
            </accesses>

            <rewrites>
                <rewrite condition="-f{OR}-l{OR}-d" target="" flag="L"/>
            </rewrites>
            
            <locations>
                <location condition="headersTest.*">
                    <headers>
                        <header type="response" name="Server" value="location" override="true"/>
                        <header type="response" name="X-Powered-By" value="location" override="true"/>
                    </headers>
                </location>
                <location condition="\/(icons|test).*">
                    <handlers>
                        <handler name="proxy" extension=".*">
                            <params>
                                <param name="transport" type="string">tcp</param>
                                <param name="upstream" type="string">backend</param>
                            </params>
                        </handler>
                    </handlers>
                </location>
            </locations>

            <virtualHosts>

                <virtualHost name="phpwebserver.dev phpwebserver.local phpwebserver.test">
                    <headers>
                        <header type="response" name="Server" value="phpwebserver.dev PHP SERVER" override="true" />
                        <header type="response" name="X-Powered-By-Vhost" value="phpwebserver.dev" />
                    </headers>
                    <locations>
                        <location condition=".*">
                            <headers>
                                <header type="response" name="Server" value="location" override="true"/>
                                <header type="response" name="X-Powered-By" value="location" override="true"/>
                            </headers>
                        </location>
                    </locations>
                    <params>
                        <param name="admin" type="string">admin@phpwebserver.dev</param>
                        <!-- Note: it's intended to use a relative path to get content from webservers basedir/var/www -->
                        <param name="documentRoot" type="string">var/www</param>
                    </params>
                    <rewrites>
                        <rewrite condition="-f{OR}-l{OR}-d" target="" flag="L"/>
                    </rewrites>
                </virtualHost>

                <virtualHost name="phpwebserver-fcgi.dev phpwebserver-fcgi.local phpwebserver-fcgi.test">
                    <params>
                        <param name="admin" type="string">admin@phpwebserver.dev</param>
                        <!-- Note: it's intended to use a relative path to get content from webservers basedir/var/www -->
                        <param name="documentRoot" type="string">var/www/cgi</param>
                    </params>
                    <rewrites>
                        <rewrite condition="-f{OR}-l{OR}-d" target="" flag="L"/>
                    </rewrites>
                    <environmentVariables>
                        <environmentVariable condition="" definition="EXAMPLE_VARIABLE=fastcgi" />
                    </environmentVariables>
                    <locations>
                        <location condition="~*\.php(\/|\?|$)">
                            <handlers>
                                <handler name="fastcgi" extension=".php">
                                    <!--
                                    <params>
                                        <param name="host" type="string">127.0.0.1</param>
                                        <param name="port" type="integer">9000</param>
                                    </params>
                                     -->
                                </handler>
                            </handlers>
                        </location>
                    </locations>
                </virtualHost>

                <virtualHost name="magento.local">
                    <params>
                        <param name="admin" type="string">admin@magento.local</param>
                        <param name="documentRoot" type="string">/var/www/magento</param>
                    </params>
                    <rewriteMaps>
                        <rewriteMap type="\AppserverIo\WebServer\Modules\MagentoRewriteMapper">
                            <params>
                                <param name="base" type="string">instance-subdir</param>
                                <param name="dsn" type="string">mysql:host=127.0.0.1;dbname=magento;charset=utf8</param>
                                <param name="username" type="string">user</param>
                                <param name="password" type="string">pass</param>
                                <!-- this is optionally
                                <param name="rewriteTableName">table-prefix.core_url_rewrite</param>
                                <param name="storeTableName">table-prefix.core_store</param>
                                -->
                            </params>
                        </rewriteMap>
                    </rewriteMaps>
                    <rewrites>
                        <rewrite condition="-f{OR}-l{OR}-d" target="" flag="L"/>
                    </rewrites>
                    <accesses>
                        <access type="allow">
                            <params>
                                <param name="X_REQUEST_URI" type="string">^\/(media|skin|js|index\.php).*</param>
                            </params>
                        </access>
                    </accesses>
                </virtualHost>

                <virtualHost name="neos.local">
                    <params>
                        <param name="admin" type="string">admin@neos.local</param>
                        <param name="documentRoot" type="string">/var/www/Neos-1.0.2/Web</param>
                    </params>
                    <rewrites>
                        <rewrite condition="^/(_Resources/Packages/|robots\.txt|favicon\.ico){OR}-d{OR}-f{OR}-l" target="" flag="L" />
                        <rewrite condition="^/(_Resources/Persistent/[a-z0-9]+/(.+/)?[a-f0-9]{40})/.+(\..+)" target="$1$3" flag="L" />
                        <rewrite condition="^/(_Resources/Persistent/.{40})/.+(\..+)" target="$1$2" flag="L" />
                        <rewrite condition="^/_Resources/.*" target="" flag="L" />
                        <rewrite condition="(.*)" target="index.php" flag="L" />
                    </rewrites>
                    <environmentVariables>
                        <environmentVariable condition="" definition="FLOW_REWRITEURLS=1" />
                        <environmentVariable condition="" definition="FLOW_CONTEXT=Production" />
                        <environmentVariable condition="Basic ([a-zA-Z0-9\+/=]+)@$Authorization" definition="REMOTE_AUTHORIZATION=$1" />
                    </environmentVariables>
                </virtualHost>
            </virtualHosts>

            <environmentVariables>
                <environmentVariable condition="" definition="LOGGER_ACCESS=Access" />
                <environmentVariable condition="(\\s.*WebKit?|Gecko)@$User-Agent" definition="BROWSER_ENGINE=$1" />
            </environmentVariables>

            <rewrites>
                <rewrite condition="-f{OR}-l{OR}-d" target="" flag="L"/>
            </rewrites>

            <connectionHandlers>
                <connectionHandler type="\AppserverIo\WebServer\ConnectionHandlers\HttpConnectionHandler" />
            </connectionHandlers>

            <modules>
                <!-- REQUEST_POST hook -->
                <module type="\AppserverIo\WebServer\Modules\AuthenticationModule" />
                <module type="\AppserverIo\WebServer\Modules\VirtualHostModule" />
                <module type="\AppserverIo\WebServer\Modules\EnvironmentVariableModule" />
                <module type="\AppserverIo\WebServer\Modules\RewriteMapModule" />
                <module type="\AppserverIo\WebServer\Modules\RewriteModule" />
                <module type="\AppserverIo\WebServer\Modules\DirectoryModule" />
                <module type="\AppserverIo\WebServer\Modules\AccessModule" />
                <module type="\AppserverIo\WebServer\Modules\LocationModule" />
                <module type="\AppserverIo\WebServer\Modules\AutoIndexModule" />
                <module type="\AppserverIo\WebServer\Modules\CoreModule" />
                <module type="\AppserverIo\WebServer\Modules\FcgiModule" />
                <module type="\AppserverIo\WebServer\Modules\ProxyModule" />
                <!-- RESPONSE_PRE hook -->
                <module type="\AppserverIo\WebServer\Modules\HeaderModule" />
                <module type="\AppserverIo\WebServer\Modules\DeflateModule" />
            </modules>
            <handlers>
                <handler name="fastcgi" extension=".php"/>
                <handler name="fastcgi" extension=".phtml"/>
                <handler name="servlet" extension=".do"/>
            </handlers>
        </server>

        <server
            name="httpsServer"
            type="\AppserverIo\Server\Servers\MultiThreadedServer"
            worker="\AppserverIo\Server\Workers\ThreadWorker"
            socket="\AppserverIo\Server\Sockets\StreamSocket"
            streamContext="\AppserverIo\Server\Contexts\StreamContext"
            serverContext="\AppserverIo\Server\Contexts\ServerContext"
            requestContext="\AppserverIo\Server\Contexts\RequestContext"
            loggerName="System">

            <params>
                <param name="admin" type="string">www@localhost.localdomain</param>
                <param name="software" type="string">phpWebServer/7.0.0</param>
                <param name="workerNumber" type="integer">64</param>
                <param name="workerAcceptMin" type="integer">16</param>
                <param name="workerAcceptMax" type="integer">64</param>
                <param name="transport" type="string">ssl</param>
                <param name="address" type="string">0.0.0.0</param>
                <param name="port" type="integer">9443</param>
                <!-- Note: it's intended to use a relative path to get content from webservers basedir/var/www -->
                <param name="documentRoot" type="string">var/www</param>
                <param name="directoryIndex" type="string">index.php index.html index.htm</param>
                <param name="keepAliveMax" type="integer">64</param>
                <param name="keepAliveTimeout" type="integer">5</param>
                <param name="autoIndex" type="boolean">false</param>
                <param name="errorsPageTemplatePath" type="string">resources/templates/www/error.phtml</param>
                <param name="welcomePageTemplatePath" type="string">resources/templates/www/welcome.phtml</param>
                <param name="autoIndexTemplatePath" type="string">resources/templates/www/auto_index.phtml</param>
                <param name="certPath" type="string">etc/webserver.pem</param>
                <param name="passphrase" type="string">passphrase</param>
            </params>

            <certificates>
                <certificate domain="phpwebserver.dev" certPath="etc/webserver.pem"/>
                <certificate domain="phpwebserver.local" certPath="etc/webserver1.pem"/>
                <certificate domain="phpwebserver.test" certPath="etc/webserver2.pem"/>
            </certificates>

            <virtualHosts>

                <virtualHost name="phpwebserver.dev phpwebserver.local phpwebserver.test">
                    <params>
                        <param name="admin" type="string">admin@phpwebserver.dev</param>
                        <!-- Note: it's intended to use a relative path to get content from webservers basedir/var/www -->
                        <param name="documentRoot" type="string">var/www</param>
                    </params>
                    <rewrites>
                        <rewrite condition="-f{OR}-l{OR}-d" target="" flag="L"/>
                    </rewrites>
                    <environmentVariables>
                        <environmentVariable condition="" definition="EXAMPLE_VARIABLE=test" />
                    </environmentVariables>
                </virtualHost>

                <virtualHost name="phpwebserver-fcgi.dev phpwebserver-fcgi.local phpwebserver-fcgi.test">
                    <params>
                        <param name="admin" type="string">admin@phpwebserver.dev</param>
                        <!-- Note: it's intended to use a relative path to get content from webservers basedir/var/www -->
                        <param name="documentRoot" type="string">var/www/cgi</param>
                    </params>
                    <rewrites>
                        <rewrite condition="-f{OR}-l{OR}-d" target="" flag="L"/>
                    </rewrites>
                    <environmentVariables>
                        <environmentVariable condition="" definition="EXAMPLE_VARIABLE=fastcgi" />
                    </environmentVariables>
                    <locations>
                        <location condition="~*\.php(\/|\?|$)">
                            <handlers>
                                <handler name="fastcgi" extension=".php">
                                    <!--
                                    <params>
                                        <param name="host" type="string">127.0.0.1</param>
                                        <param name="port" type="integer">9000</param>
                                    </params>
                                     -->
                                </handler>
                            </handlers>
                        </location>
                    </locations>
                </virtualHost>

                <virtualHost name="magento.local">
                    <params>
                        <param name="admin" type="string">admin@magento.local</param>
                        <param name="documentRoot" type="string">/var/www/magento</param>
                    </params>
                    <rewriteMaps>
                        <rewriteMap type="\AppserverIo\WebServer\Modules\MagentoRewriteMapper">
                            <params>
                                <param name="base" type="string">instance-subdir</param>
                                <param name="dsn" type="string">mysql:host=127.0.0.1;dbname=magento;charset=utf8</param>
                                <param name="username" type="string">user</param>
                                <param name="password" type="string">pass</param>
                                <!-- this is optionally
                                <param name="rewriteTableName">table-prefix.core_url_rewrite</param>
                                <param name="storeTableName">table-prefix.core_store</param>
                                -->
                            </params>
                        </rewriteMap>
                    </rewriteMaps>
                    <rewrites>
                        <rewrite condition="-f{OR}-l{OR}-d" target="" flag="L"/>
                    </rewrites>
                    <accesses>
                        <access type="allow">
                            <params>
                                <param name="X_REQUEST_URI" type="string">^\/(media|skin|js|index\.php).*</param>
                            </params>
                        </access>
                    </accesses>
                </virtualHost>

                <virtualHost name="neos.local">
                    <params>
                        <param name="admin" type="string">admin@neos.local</param>
                        <param name="documentRoot" type="string">/var/www/Neos-1.0.2/Web</param>
                    </params>
                    <rewrites>
                        <rewrite condition="^/(_Resources/Packages/|robots\.txt|favicon\.ico){OR}-d{OR}-f{OR}-l" target="" flag="L" />
                        <rewrite condition="^/(_Resources/Persistent/[a-z0-9]+/(.+/)?[a-f0-9]{40})/.+(\..+)" target="$1$3" flag="L" />
                        <rewrite condition="^/(_Resources/Persistent/.{40})/.+(\..+)" target="$1$2" flag="L" />
                        <rewrite condition="^/_Resources/.*" target="" flag="L" />
                        <rewrite condition="(.*)" target="index.php" flag="L" />
                    </rewrites>
                    <environmentVariables>
                        <environmentVariable condition="" definition="FLOW_REWRITEURLS=1" />
                        <environmentVariable condition="" definition="FLOW_CONTEXT=Production" />
                        <environmentVariable condition="Basic ([a-zA-Z0-9\+/=]+)@$Authorization" definition="REMOTE_AUTHORIZATION=$1" />
                    </environmentVariables>
                </virtualHost>
                
            </virtualHosts>

            <environmentVariables>
                <environmentVariable condition="(\\s.*WebKit?|Gecko)@$User-Agent" definition="BROWSER_ENGINE=$1" />
            </environmentVariables>

            <rewrites>
                <rewrite condition="-f{OR}-l{OR}-d" target="" flag="L"/>
            </rewrites>

            <authentications>
                <authentication uri="^\/auth\/basic\/.*">
                    <params>
                        <param name="type" type="string">\AppserverIo\Http\Authentication\BasicAuthentication</param>
                        <param name="realm" type="string">PhpWebServer Basic Authentication System</param>
                        <param name="file" type="string">resources/auth/basic/.htpasswd</param>
                    </params>
                </authentication>
                <authentication uri="^\/auth\/digest\/.*">
                    <params>
                        <param name="type" type="string">\AppserverIo\Http\Authentication\DigestAuthentication</param>
                        <param name="realm" type="string">appserver.io Digest Authentication System</param>
                        <param name="file" type="string">resources/auth/digest/.htpasswd</param>
                    </params>
                </authentication>
            </authentications>

            <accesses>
                <access type="allow">
                    <params>
                        <param name="X_REQUEST_URI" type="string">.*</param>
                    </params>
                </access>
                <access type="deny">
                    <params>
                        <param name="X_REQUEST_URI" type="string">^\/var\/.*</param>
                    </params>
                </access>
            </accesses>

            <connectionHandlers>
                <connectionHandler type="\AppserverIo\WebServer\ConnectionHandlers\HttpConnectionHandler" />
            </connectionHandlers>

            <modules>
                <!-- REQUEST_POST hook -->
                <module type="\AppserverIo\WebServer\Modules\AuthenticationModule" />
                <module type="\AppserverIo\WebServer\Modules\VirtualHostModule" />
                <module type="\AppserverIo\WebServer\Modules\EnvironmentVariableModule" />
                <module type="\AppserverIo\WebServer\Modules\RewriteMapModule" />
                <module type="\AppserverIo\WebServer\Modules\RewriteModule" />
                <module type="\AppserverIo\WebServer\Modules\DirectoryModule" />
                <module type="\AppserverIo\WebServer\Modules\AccessModule" />
                <module type="\AppserverIo\WebServer\Modules\LocationModule" />
                <module type="\AppserverIo\WebServer\Modules\AutoIndexModule" />
                <module type="\AppserverIo\WebServer\Modules\CoreModule" />
                <module type="\AppserverIo\WebServer\Modules\FcgiModule"/>
                <!-- RESPONSE_PRE hook -->
                <module type="\AppserverIo\WebServer\Modules\HeaderModule" />
                <module type="\AppserverIo\WebServer\Modules\DeflateModule"/>
            </modules>
            <handlers>
                <handler name="fastcgi" extension=".php"/>
                <handler name="fastcgi" extension=".phtml"/>
                <handler name="servlet" extension=".do"/>
            </handlers>
        </server>
    </servers>

</config>