Search code examples
pythonapachetornado

How to config apache reply for some request and not sent that for tornado


I have a web site that wrote by python and tornado. Apache is my web server.

<VirtualHost *:80>
    ServerName food.domain.com
    ProxyPass /  http://127.0.0.1:8004/ retry=0 acquire=3000 timeout=600 Keepalive=On

    ProxyPassReverse / http://127.0.0.1:8004/
    ProxyPreserveHost On

    DocumentRoot /var/food

    <Directory /var/food/ >
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/php.error.log
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

In my site the static files begins with /static for example:

http://food.domain.com/static/favicon.ico
http://food.domain.com/static/upload/main/20x20_73213076755756.png

Now apache remise all urls to tornado server.

I want the URLS begin with static not send to tornado and that file replayed by apache or otherwise.

what is best solution?


Solution

  • You can simply exclude that path from ProxyPass with exclamation mark:

    <VirtualHost *:80>
        ServerName food.domain.com
    
        DocumentRoot /var/food
        ProxyPass /static !
    
        ProxyPass /  http://127.0.0.1:8004/ retry=0 acquire=3000 timeout=600 Keepalive=On
    
        ProxyPassReverse / http://127.0.0.1:8004/
        ProxyPreserveHost On
    
        <Directory /var/food/ >
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
    
        ErrorLog ${APACHE_LOG_DIR}/php.error.log
        LogLevel warn
    
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    

    If your statics are at /var/food/static then there is nothing else to do.