![]() |
ReverseProxy is a component that sits in front of web server(s) or app server(s), and routes requests to the corresponding server based on configuration. The advantage of this approach is:
Using apache or even lighttpd for reverse proxy seems overkill. On nslu2 with optware, pound and nginx are two lightweight reverse proxy servers. Pound is strictly a "reverse proxy and load balancer", while nginx can also connect to upstream (backend) PHP server with fastcgi protocol and serve static content. It makes a lot of sense to use nginx on the slug, especially in the following scenarios:
Let's say we want to test nginx (localhost:7007) in front of cherokee (localhost:8008, an example of http web/app server) and PHP (localhost:9009, an example of fastcgi). PreparationInstall cherokee and php-fcgi # ipkg update # ipkg install cherokee # ipkg install php-fcgi
Verify php-fcgi version # /opt/bin/php-fcgi -v PHP 5.1.6 (cgi-fcgi) (built: Aug 25 2006 08:50:32) ... Prepare a simple info.php, with just a single line of # mkdir -p /opt/share/www/php # echo "<?php phpinfo(); ?>" > /opt/share/www/phpinfo.php Install, config & test nginx.Basic setup Change Launch nginx
Add cherokeeAdd the following lines to /opt/etc/nginx/nginx.conf http server section: location /cherokee/ { proxy_pass http://127.0.0.1:8008/; proxy_redirect default; } Restart nginx # killall nginx # /opt/sbin/nginx
Add php-fcgiAdd the following lines to location ~ \.php$ { fastcgi_pass 127.0.0.1:9009; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /opt/share/www/php/$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; } Launching php-fcgi Restart nginx # killall nginx # /opt/sbin/nginx
Tighten securityTry to run PHP or app server as non-root, and only pass certain environment variables to PHP. See reference. References
Page PasswordDue to spam, lock the page with password being the same as page title, all lower case.
view ·
edit ·
print ·
history ·
Last edited by colin gebhart.
Based on work by colin gebhart, BrianZhou, Kwbafenc, Pcygukdb, Ugufayes, Mpgmrppl, Xxfcerfo, Kbgpcmlo, Kobfzqpg, Woxtqqtf, Scldsvqr, Pahlsygx, olivier heinry, Tqgghhew, fcarolo, Cicgpswl, Vwtkzgns, mikle, and Marcelo. Originally by BrianZhou. Page last modified on October 07, 2008, at 07:57 PM
|