Adding ProxyPass and ProxyPassReverse using mod_wsgi-express

350 views
Skip to first unread message

peter hoth

unread,
Oct 7, 2016, 5:04:57 AM10/7/16
to modwsgi
Hi,

I managed to install both mod_wsgi-express and mod_wsgi_httpd and get my site working by calling mod_wsgi-express with the standard parameters to generate the httpd.conf file.

Now, i have implemented a xmpp server and would like to incorporate it into my site. The requirements are that i need to install the proxy module and add the following lines to the apache config file.

sudo a2enmod proxy
sudo a2enmod proxy_http

Add to apache config file:

<VirtualHost *:443>
  ServerName mywebapp.com
  :
  ProxyPass /http-bind/ http://localhost:5280/http-bind/
  ProxyPassReverse /http-bind/ http://localhost:5280/http-bind/
  :
</VirtualHost>


In the generated httpd.conf file, i can see the following lines:

:
<IfDefine MOD_WSGI_WITH_PROXY>
<IfModule !proxy_module>
LoadModule proxy_module ${MOD_WSGI_MODULES_DIRECTORY}/mod_proxy.so
</IfModule>
<IfModule !proxy_http_module>
LoadModule proxy_http_module ${MOD_WSGI_MODULES_DIRECTORY}/
mod_proxy_http.so
</IfModule>
</
IfDefine>
:

Q1. What parameters should i pass to mod_wsgi-express to get it to configure the httpd.conf to include the modules ?

Q2. Can I use mod_wsgi-express to help me to add in the proxy lines or do i need to manually go through the <IfDefine> lines in the generated httpd.conf to see where to add in the lines ?

Thanks.

Graham Dumpleton

unread,
Oct 7, 2016, 5:15:51 AM10/7/16
to mod...@googlegroups.com
On 7 Oct 2016, at 7:59 PM, peter hoth <hoth....@gmail.com> wrote:

Hi,

I managed to install both mod_wsgi-express and mod_wsgi_httpd and get my site working by calling mod_wsgi-express with the standard parameters to generate the httpd.conf file.

Be aware that there is no need to use the mod_wsgi-httpd package if you already have Apache httpd server installed as a system package, along with the appropriate Apache httpd dev packages for it. In other words, use the system Apache if you can, the pip installable mod_wsgi-httpd is only for if you have no other choice for getting Apache httpd server installed.

Now, i have implemented a xmpp server and would like to incorporate it into my site. The requirements are that i need to install the proxy module and add the following lines to the apache config file.
sudo a2enmod proxy
sudo a2enmod proxy_http

Add to apache config file:

<VirtualHost *:443>
  ServerName mywebapp.com
  :
  ProxyPass /http-bind/ http://localhost:5280/http-bind/
  ProxyPassReverse /http-bind/ http://localhost:5280/http-bind/
  :
</VirtualHost>


In the generated httpd.conf file, i can see the following lines:

:
<IfDefine MOD_WSGI_WITH_PROXY>
<IfModule !proxy_module>
LoadModule proxy_module ${MOD_WSGI_MODULES_DIRECTORY}/mod_proxy.so
</IfModule>
<IfModule !proxy_http_module>
LoadModule proxy_http_module ${MOD_WSGI_MODULES_DIRECTORY}/
mod_proxy_http.so
</IfModule>
</
IfDefine>
:

Q1. What parameters should i pass to mod_wsgi-express to get it to configure the httpd.conf to include the modules ?
Q2. Can I use mod_wsgi-express to help me to add in the proxy lines or do i need to manually go through the <IfDefine> lines in the generated httpd.conf to see where to add in the lines ?

It isn’t clear as to which Apache instance you want to be the front facing site, the system Apache or the one used by mod_wsgi-express. Also be aware that the mod_wsgi-express generated Apache configuration has got nothing to do with the system Apache installation. Nothing you do with mod_wsgi-express will change the system Apache installation setup. The mod_wsgi-express instance of Apache runs entirely separately.

So can you clarify what is running in the system Apache and do you want the system Apache to be the front end Apache which then proxies only specific requests through to mod_wsgi-express? Or do you want mod_wsgi-express to be the front end Apache instance, with it proxying to the system Apache? That you are talking about proxy setups in both is a bit confusing.

If you do have something significant running on the system Apache, you may be better off just loading mod_wsgi into the system Apache, configuring mod_wsgi manually, and not use mod_wsgi-express.

Graham

peter hoth

unread,
Oct 7, 2016, 7:37:20 AM10/7/16
to modwsgi
Hi Graham,

1. I have disabled the Apache that comes with the system and i am using the Apache instance installed with the mod_wsgi_httpd

2. I am currently using the Apache instance with the configuration generated by the mod_wsgi-express and it is currently running.

3. I have installed a running XMPP server in the same machine and i have manually configured the apachectl  and httpd files (both created by the mod_wsgi_httpd and mod_wsgi-express and not the system Apache files)
   a. I manually appended "-DMOD_WSGI_WITH_PROXY" to the end of the line "HTTPD_ARGS" in the apachectl file
   b. I manually inserted the lines to the mod_wsgi-express generated file httpd.conf
         :
         ProxyPass /http-bind/ http://localhost:5280/http-bind/
         ProxyPassReverse /http-bind/ http://localhost:5280/http-bind/
         :

4. I am wondering if based on the required changes, is it possible that I use mod_wsgi-express to make the changes for me by simply passing parameters to it.

Thanks.

Graham Dumpleton

unread,
Oct 7, 2016, 7:47:31 AM10/7/16
to mod...@googlegroups.com
Rather than explain what you have done, can you explain what you want to do?

I can’t see any reason why you would want to do what it seems you are trying to do.

On 7 Oct 2016, at 10:37 PM, peter hoth <hoth....@gmail.com> wrote:

Hi Graham,

1. I have disabled the Apache that comes with the system and i am using the Apache instance installed with the mod_wsgi_httpd

Is there are reason you aren’t using the system Apache?

2. I am currently using the Apache instance with the configuration generated by the mod_wsgi-express and it is currently running.

How are you running that? By running ‘mod_wsgi-express start-server’, or by running ‘apachectl’ in generated configuration directory after having used ‘mod_wsgi-express setup-server’.

3. I have installed a running XMPP server in the same machine and i have manually configured the apachectl  and httpd files (both created by the mod_wsgi_httpd and mod_wsgi-express and not the system Apache files)

This bit doesn’t make sense. Why are you trying to use the Apache configuration files generated by mod_wsgi-express with your XMPP Apache instance? That is not the purpose of mod_wsgi-express, it is a self contained system, it is not intended to be used to generate a configuration for a separate Apache installation.

   a. I manually appended "-DMOD_WSGI_WITH_PROXY" to the end of the line "HTTPD_ARGS" in the apachectl file
   b. I manually inserted the lines to the mod_wsgi-express generated file httpd.conf 
         :
         ProxyPass /http-bind/ http://localhost:5280/http-bind/
         ProxyPassReverse /http-bind/ http://localhost:5280/http-bind/
         :

If there was a valid reason to have mod_wsgi-express proxy some sub URL to a backend site, you would use the option:

    --proxy-mount-point /http-bind http://localhost:5280/http-bind/

when running mod_wsgi-express.

4. I am wondering if based on the required changes, is it possible that I use mod_wsgi-express to make the changes for me by simply passing parameters to it. 

Please go back and explain what you are wanting to do, rather than describe what you think is the solution. Do you actually have a Python web application you want to run?

Graham

-- 
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

peter hoth

unread,
Oct 7, 2016, 9:08:56 AM10/7/16
to modwsgi

I am using CentOS 6.8 which comes with Apache 2.2 and i was having trouble getting it to work with mod_wsgi that i decided to install mod_wsgi_httpd with mod_wsgi-express following the steps from the web. Anyway, the Apache instance from mod_httpd is of version 2.4 which i assume should be better.

As i am not an expert on configuring httpd.conf, I use the mod_wsgi-express setup-server with parameters to generate the httpd.conf file and use the apachectl start to start the server.

My python web app is working fine with this new setup.

I have just installed a chat server in the same machine. I just want to configure the Apache instance to act as a proxy to forward a HTTP connection to the chat server when the client connects to the Apache server with the url https://webserver.com/http-bind

I managed to get it to work by manually configuring the files in my previous post. I was just thinking if mod_wsgi_express can actually do the same thing by simply passing some parameters.

I will try the --proxy-mount-point option as you suggested to see if it does configure the httpd.conf to load the proxy modules and perform the proxy service.

I apologize if my explanation is not clear.

Thanks.

Graham Dumpleton

unread,
Oct 9, 2016, 7:42:29 PM10/9/16
to mod...@googlegroups.com
On 8 Oct 2016, at 12:08 AM, peter hoth <hoth....@gmail.com> wrote:


I am using CentOS 6.8 which comes with Apache 2.2 and i was having trouble getting it to work with mod_wsgi that i decided to install mod_wsgi_httpd with mod_wsgi-express following the steps from the web. Anyway, the Apache instance from mod_httpd is of version 2.4 which i assume should be better. 

Apache 2.2 is generally okay so long as have a version of mod_wsgi newer than 4.4.13.

In the past Apache 2.2 has been a bit of an issue with extra memory usage due to the design of Apache itself. Recent mod_wsgi versions use various tricks to workaround design issues in older Apache versions. Apache 2.4 fixed some of those issues and changed some default settings so was better, but even then recent mod_wsgi version with Apache 2.4 is still better as well. If do use Apache 2.2, still a good idea to go back and set MaxMemFree directive to some sensible value. In Apache 2.2 there is no limit set and so per request memory pools in Apache can grow and don’t release memory back to rest of process, so one request that consumes a large amount of transient memory can blow out memory usage of process. In Apache 2.4, the default for MaxMemFree is now 2048. In mod_wsgi-express I actual set it as low as 64.

As i am not an expert on configuring httpd.conf, I use the mod_wsgi-express setup-server with parameters to generate the httpd.conf file and use the apachectl start to start the server. 

Just to clarify some confusion. You are using the ‘apachectl’ in the generated Apache configuration file and so still effectively running mod_wsgi-express, or as I infer so far, you then copy the generated configuration and use it with a completely different Apache installation? Doing the latter is not a good idea as the generated configuration would be setup for the specific Apache installation and may not work properly with another Apache installation.

Graham
Reply all
Reply to author
Forward
0 new messages