Apache Mod_wsgi through ProxyPass

1,493 views
Skip to first unread message

Piotr Michal

unread,
Jun 30, 2015, 4:28:27 PM6/30/15
to mod...@googlegroups.com
Hi

I have an Apache server with few virtual hosts I'm trying to add dockerised apache with mod_wsgi as another virtual host using ProxyPass solution suggested by Graham

http://serverfault.com/questions/701634/running-docker-with-apache-wsgi-side-by-side-with-apache

I'm trying to use it in normal mod_wsgi which I compiled from source to version 4.4.13 (I'm not familar with mod_wsgi-express )

and I set WSGITrustedProxyHeaders to X-Forwarded-Server X-Forwarded-Port X-Forwarded-For

unfortunately I still have

502 Proxy Error

It looks like something is not working

settings for dockerised apache are as follows

WSGIScriptAlias / /var/www/html/django/Django/wsgi.py
WSGIPythonPath /var/www/html/django:/var/www/html/django/lib/python2.7/site-packages

<VirtualHost *:80>
  ServerName test.co.uk
  ServerAlias django.test.co.uk
  WSGITrustedProxyHeaders X-Forwarded-Server X-Forwarded-Port X-Forwarded-For


  ErrorLog logs/django_error_log
  CustomLog logs/django_access_log common

  Alias /static/ "/var/www/html/django/Django/test/"
  <Directory /var/www/html/django/Django/test/>
      Order deny,allow
      Allow from all
  </Directory>


  <Directory /var/www/html/django/Django>
    <Files wsgi.py>
      Order deny,allow
      Allow from all
    </Files>
  </Directory>
</VirtualHost>


and settings of the apache proxy

<VirtualHost *:80>
  ServerAlias django.test.co.uk
  ServerName django.test.co.uk
  ProxyPass / http://112.22.16.23:8080
  ProxyPassReverse / http://112.22.16.23:8080
  ErrorLog logs/django_error_log
  CustomLog logs/django_access_log common

  RequestHeader set X-Forwarded-Port 80
</VirtualHost>

Any ideas?

Graham Dumpleton

unread,
Jun 30, 2015, 5:07:06 PM6/30/15
to mod...@googlegroups.com
On 1 Jul 2015, at 2:11 am, Piotr Michal <zgr...@googlemail.com> wrote:

Hi

I have an Apache server with few virtual hosts I'm trying to add dockerised apache with mod_wsgi as another virtual host using ProxyPass solution suggested by Graham

http://serverfault.com/questions/701634/running-docker-with-apache-wsgi-side-by-side-with-apache

Which was in turn referring to my blog post from yesterday.


Already working on the next blog post which goes into further issues about static files.

I'm trying to use it in normal mod_wsgi which I compiled from source to version 4.4.13 (I'm not familar with mod_wsgi-express )

and I set WSGITrustedProxyHeaders to X-Forwarded-Server X-Forwarded-Port X-Forwarded-For

unfortunately I still have

502 Proxy Error

It looks like something is not working

settings for dockerised apache are as follows

WSGIScriptAlias / /var/www/html/django/Django/wsgi.py
WSGIPythonPath /var/www/html/django:/var/www/html/django/lib/python2.7/site-packages

<VirtualHost *:80>
  ServerName test.co.uk
  ServerAlias django.test.co.uk
  WSGITrustedProxyHeaders X-Forwarded-Server X-Forwarded-Port X-Forwarded-For

Rather than X-Forwarded-Server, it should be X-Forwarded-Host.

  ErrorLog logs/django_error_log
  CustomLog logs/django_access_log common

  Alias /static/ "/var/www/html/django/Django/test/"
  <Directory /var/www/html/django/Django/test/>
      Order deny,allow
      Allow from all
  </Directory>


  <Directory /var/www/html/django/Django>
    <Files wsgi.py>
      Order deny,allow
      Allow from all
    </Files>
  </Directory>
</VirtualHost>


and settings of the apache proxy

<VirtualHost *:80>
  ServerAlias django.test.co.uk
  ServerName django.test.co.uk
  ProxyPass / http://112.22.16.23:8080
  ProxyPassReverse / http://112.22.16.23:8080

It is important that the final arguments on ProxyPass and ProxyPassReverse have a trailing slash.

  ProxyPass / http://112.22.16.23:8080/
  ProxyPassReverse / http://112.22.16.23:8080/

I actually screwed up the blog post initially and left them off in a few places. You may have seen it before i corrected it.

  ErrorLog logs/django_error_log
  CustomLog logs/django_access_log common

  RequestHeader set X-Forwarded-Port 80
</VirtualHost>

Any ideas?

Graham

Graham Dumpleton

unread,
Jul 1, 2015, 1:04:26 AM7/1/15
to mod...@googlegroups.com
On 1 Jul 2015, at 7:06 am, Graham Dumpleton <graham.d...@gmail.com> wrote:


On 1 Jul 2015, at 2:11 am, Piotr Michal <zgr...@googlemail.com> wrote:

Hi

I have an Apache server with few virtual hosts I'm trying to add dockerised apache with mod_wsgi as another virtual host using ProxyPass solution suggested by Graham

http://serverfault.com/questions/701634/running-docker-with-apache-wsgi-side-by-side-with-apache

Which was in turn referring to my blog post from yesterday.


Already working on the next blog post which goes into further issues about static files.

Here is the followup post which talks about issues around serving static files from behind a proxy.


Graham

Piotr Michal

unread,
Jul 1, 2015, 6:43:16 AM7/1/15
to mod...@googlegroups.com
Thank you for your time and quick response that was it, its working like a charm now.
Reply all
Reply to author
Forward
0 new messages