I'm a newbie and I started to write an application in Pylons.
When in the future the application will be used in a production
environment, can I use only paster to serve the application? In that
case, which are the steps to do that?
I'm sorry for the stupid question, but in my searches, I founded only
explanations for the use with apache, mod_wsgi, mod_python.
many people serve moderately trafficked sites through paster, myself
included.
the two things you'd need to do are:
1- Make a shell script to handle startup / shutdown
2- install something like nginx on port 80 , and have that handle the
static files or file directories ( js / css /images / etc ); then just
proxy everything else to paster
> many people serve moderately trafficked sites through paster, myself > included.
> the two things you'd need to do are:
> 1- Make a shell script to handle startup / shutdown > 2- install something like nginx on port 80 , and have that handle the > static files or file directories ( js / css /images / etc ); then just > proxy everything else to paster
He was asking about using Paster alone without a webserver. Yes, you can do this. There are three reasons most people use Apache or Nginx:
1. To use its features: SSL, virtual hosts, rewriting, authentication, fast static files, caching, etc. 2. Apache is very widely used and has a long track record, so many people feel safer about letting it handle SSL. 3. Apache can clean up misformatted requests from substandard user agents, which might inconvenience or crash the Paster routine.
I use Paster with ProxyPass, and run it under Supervisor rather than using a startup script.
On Oct 27, 3:58 pm, Mike Orr <sluggos...@gmail.com> wrote:
> I use Paster with ProxyPass, and run it under Supervisor rather than
> using a startup script.
that too! i need to learn how to do that. i had a hellish experience
trying to get monit to work correctly for this; supervisor is likely
to be more portable and simpler.
> He was asking about using Paster alone without a webserver. Yes, you
> can do this. There are three reasons most people use Apache or Nginx:
my interpretation was that he didn't want to config apache or similar
to handle the application, and serve from paster -- which is what i
suggested.
perhaps i should have been more clear and said this:
You can serve from paster alone, but it may not be a good idea to
do that.
Paster can definitely handle the traffic for all of your dynamic
content on most sites quite easily; but each dynamic page usually has
a significant amount of static content - serving that static content
off Paster will slow everything down. You'll also run into issue with
'slow clients' or 'dropped connections' that tie up processes/threads/
etc -- which is really universal to all web applications no matter the
framework or language. For that reason many people like to run some
sort of webserver on Port 80 in front of their dynamic server(s) ;
this server is usually responsible for serving static content and
proxying the request for dynamic content to a Paster / Apache / FCGI /
etc server operating on a different port or even a different
machine. The benefits of this setup are that the dynamic server
receives a completed request and can quickly process it and return it
to the proxy server on port 80, freeing up memory/cpu resources
quickly. The proxy essentially only serves static content, and is
usually highly optimized code that can handle thousands of
simultaneous connections ( ie: nginx, lighttpd, etc ).
1. mod_security or its equivalent (sub-bullet of Mike's #1 but I think
it's important to call out)
2. if you light up paster with a load balancer on a quad core machine
(at least, if you did it two years ago like we did), only one CPU will
reach 100% utilization. we were set up to proxy to four paster
instances per box, using apache as a front end. worked like a dream.
On Tue, Oct 27, 2009 at 12:58 PM, Mike Orr <sluggos...@gmail.com> wrote:
> On Tue, Oct 27, 2009 at 12:47 PM, Jonathan Vanasco
> <jonat...@findmeon.com> wrote:
>> many people serve moderately trafficked sites through paster, myself
>> included.
>> the two things you'd need to do are:
>> 1- Make a shell script to handle startup / shutdown
>> 2- install something like nginx on port 80 , and have that handle the
>> static files or file directories ( js / css /images / etc ); then just
>> proxy everything else to paster
> He was asking about using Paster alone without a webserver. Yes, you
> can do this. There are three reasons most people use Apache or Nginx:
> 1. To use its features: SSL, virtual hosts, rewriting, authentication,
> fast static files, caching, etc.
> 2. Apache is very widely used and has a long track record, so many
> people feel safer about letting it handle SSL.
> 3. Apache can clean up misformatted requests from substandard user
> agents, which might inconvenience or crash the Paster routine.
> I use Paster with ProxyPass, and run it under Supervisor rather than
> using a startup script.
# Proxy
ProxyPass / http://localhost:8080/ retry=5
ProxyPassReverse / http://localhost:8080/ ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
Now, the apache web server that I'll use, serve a principal domain
(www.cerm.unifi.it) and other virtual host based on its names.
I would that all coming requests for https://www.cerm.unifi.it:5001 or
http://www.cerm.unifi.it:5001 has to be redirect to my pylons
application. I cannot understand how do that. Because from the example
seems that all request to www.pylonsbook.com are redirect to the port
8080 where the paster is listen. Instead I want the only the requests
to the 5001 port of the base site are to be redirected.
> Now, the apache web server that I'll use, serve a principal domain
> (www.cerm.unifi.it) and other virtual host based on its names.
> I would that all coming requests forhttps://www.cerm.unifi.it:5001orhttp://www.cerm.unifi.it:5001has to be redirect to my pylons
> application. I cannot understand how do that. Because from the example
> seems that all request towww.pylonsbook.comare redirect to the port
> 8080 where the paster is listen. Instead I want the only the requests
> to the 5001 port of the base site are to be redirected.
I was going to say that I don't think that's possible, but perhaps you
can add 'Listen 5001' to your Apache config and set up a virtualhost
using that port (don't know; never tried it). Of course, if that did
work, you'd have to run your Paste server on a different port.
> On Oct 30, 4:54 am, morellik <enrico.more...@gmail.com> wrote:
> > Now, the apache web server that I'll use, serve a principal domain
> > (www.cerm.unifi.it) and other virtual host based on its names.
> > I would that all coming requests forhttps://www.cerm.unifi.it:5001orhttp://www.cerm.unifi.it:5001hasto be redirect to my pylons
> > application. I cannot understand how do that. Because from the example
> > seems that all request towww.pylonsbook.comareredirect to the port
> > 8080 where the paster is listen. Instead I want the only the requests
> > to the 5001 port of the base site are to be redirected.
Most people wouldn't do that. It's an odd setup.
Typically people do this :
- Front-End server on port 80
- All "upper level" ports locked down to localhost only
- Front-end server proxies certain traffic on port 80 -- based on
virtual host settings, location match, etc , to Paster or other
application running on port 5000, 8080, etc
to get your behavior - which is odd - you can do two things :
- run paster on port 5001 , and open up that port on iptables or
whatever ; paster will respond to those requests and there's no need
to run them through apache. apache will only bind to the ports you
request, which by default is 80. unless you tell it to listen to
5001, it's not going to -- and paster can run on that and handle
traffic directly.
- in apache put:
-- Listen 5001
-- <VirtualHost domainname.it:5001> proxy to pylons on 8080 </
VirtualHost>
personally, I'd keep all the external traffic on port 80. it's
simpler , cleaner urls, and you won't have do deal with the potential
of firewalls of your consumers's employers/isps blocking the higher
ports. i'd just set up a virtual host, and proxy everything but
static content or specific directories to the paster server on the
higher port.
> # Proxy > ProxyPass / http://localhost:8080/ retry=5 > ProxyPassReverse / http://localhost:8080/ > ProxyPreserveHost On > <Proxy *> > Order deny,allow > Allow from all > </Proxy> > </VirtualHost>
> Now, the apache web server that I'll use, serve a principal domain > (www.cerm.unifi.it) and other virtual host based on its names. > I would that all coming requests for https://www.cerm.unifi.it:5001 or > http://www.cerm.unifi.it:5001 has to be redirect to my pylons > application. I cannot understand how do that. Because from the example > seems that all request to www.pylonsbook.com are redirect to the port > 8080 where the paster is listen. Instead I want the only the requests > to the 5001 port of the base site are to be redirected.
If I understand correctly, your Pylons application is running on port 8080, and you want Apache to proxy port 5001 to it but not port 80 (i.e., port 80 will be used for a different website).
In this case you'd need two VirtualHost stanzas. You would also need "Listen" lines for all IPs/ports you want Apache to listen to. E.g.,
If you want to publish the Pylons site on *both* ports 80 and 5001 (though why would you want to?), you'd have two VirtualHost stanzas with identical directives inside them.
In any case, your Pylons application should listen only on localhost, so it gets requests only from Apache or from a console webbrowser, not from the Internet.
If you want to be tricky, you can run the Pylons app on "localhost:8080" and have Apache listen on "my-public-ip:8080", but that will probably be confusing. What you *can't* do is have two processes listen on the same IP:port combination simultaneously.
> If I understand correctly, your Pylons application is running on port
> 8080, and you want Apache to proxy port 5001 to it but not port 80
> (i.e., port 80 will be used for a different website).
Excuse me for my bad English. I dont' explain well the problem. The
Pylons applications is running on port 5001. But there aren't problems
to change the port to another (over 8000).
I wrote a lot of CherryPy applications where I set the port, start its
server and that's all.
Using Pylons, seems to be better use a web server (like Apache) to
serve the application instead using Paster directly.
Now, I have an Apache web server that serve the main web site of our
center and other virtual sites. So, I haven't a domain to bind to
Pylon application but only a port.
My question is: is there a way to configure Apache to proxy calls to
the specific port where Paster is running?