# HTTP Proxying
Many people prefer using a standalone Python HTTP server and proxying thatserver via nginx, Apache etc.
A very stable Python server is CherryPy. This part of the documentationshows you how to combine your WSGI application with the CherryPy WSGIserver and how to configure the webserver for proxying.
### Creating a .py server
To run your application you need a start-server.py file that starts upthe WSGI Server.
It looks something along these lines:
~~~
from cherrypy import wsgiserver
from yourapplication import make_app
server = wsgiserver.CherryPyWSGIServer(('localhost', 8080), make_app())
try:
server.start()
except KeyboardInterrupt:
server.stop()
~~~
If you now start the file the server will listen on localhost:8080. Keepin mind that WSGI applications behave slightly different for proxied setups.If you have not developed your application for proxying in mind, you canapply the [ProxyFix](# "werkzeug.contrib.fixers.ProxyFix") middleware.
### Configuring nginx
As an example we show here how to configure nginx to proxy to the server.
The basic nginx configuration looks like this:
~~~
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
proxy_redirect default;
}
~~~
Since Nginx doesn't start your server for you, you have to do it by yourself. Youcan either write an init.d script for that or execute it inside a screensession:
~~~
$ screen
$ python start-server.py
~~~
- 开始
- Werkzeug 文档概览
- 安装
- 过渡到 Werkzeug 1.0
- Werkzeug 教程
- API 标准
- 快速开始
- Python 3 Notes
- 服务和测试
- Debugging Applications
- 在服务器运行 WSGI 应用
- 单元测试
- 参考
- Request / Response Objects
- URL Routing
- WSGI Helpers
- HTTP Utilities
- Data Structures
- Utilities
- Context Locals
- Middlewares
- HTTP Exceptions
- 部署
- CGI
- mod_wsgi (Apache)
- FastCGI
- HTTP Proxying
- 贡献模块
- Atom Syndication
- Sessions
- Secure Cookie
- Cache
- Extra Wrappers
- Iter IO
- Fixers
- WSGI Application Profiler
- Lint Validation Middleware
- 额外说明
- Werkzeug Changelog
- Important Terms
- Unicode
- Dealing with Request Data