Hi All
I'm trying to move a bunch of rails apps from an apache/fastcgi
platform to nginx/mongrel_cluster.
What I want is something like this;
http://my.server/app1 --> mongrel_cluster1
http://my.server/app2 --> mongrel_cluster2
I can do this in nginx with something like this;
...
upstream mongrel_cluster1 {
server 127.0.0.1:3001;
server 127.0.0.1:3002;
}
upstream mongrel_cluster2 {
server 127.0.0.1:4001;
server 127.0.0.1:4002;
}
server {
...
location /app1 {
proxy_pass http://mongrel_cluster1;
break;
}
location /app2 {
proxy_pass http://mongrel_cluster2;
break;
}
...
But, the problem is that I'm now hitting my rails apps with paths like
this;
/app1/controller/method
/app2/controller/method
...when the apps want the paths to be just /controller/method
So, I want to use something like this to remove the 'app1' part;
rewrite ^/app1/(.*)$ /$1 permanent;
But, that seems to override the proxy_pass directive, because if I put
that in my location blocks, I just get 404 errors, and it's not
allowed in my upstream blocks.
I know I could use virtual hosts, with a different subdomain for each
app, but that would be this;
http://app1.my.server --> mongrel_cluster1
http://app2.my.server --> mongrel_cluster2
...which is not what I want.
Is there any way to achieve what I want, using nginx?
Thanks in advance for any help.
David
Squid has a mechanism by which incoming URL's can be passed to an
external program to be rewritten and the reverse proxy subsequently
calls out to the rewritten URL
http://wiki.squid-cache.org/SquidFaq/SquidRedirectors
Is there a way to emulate this from within nginx
Thanks, Yusuf
Is it possible to configure error_log, such a way it only contains
application specific errors? Currently nginx also logs virtual server error
messages like "No such file or directory" and others.
IMHO these messages, as well as access logs, should be contained in a
separate file (per virtual server), and not in the common error_log.
Thanks,
Athan
hi,i wanna write a module to perform traffic statistic on every vhost,but
after i read the document:"Guide to Nginx Module
Development<http://www.riceonfire.org/emiller/nginx-modules-guide.html>"
and some code in /nginx-0.6.13/src/http/modules/,i found that i still have
no idea...
is it possible to write a new module to do this work?or this feature is not
supported by current nginx?
Hi,
I'm proud to announce the availability of the first version of
nginx_uploadprogress_module (v0.1).
This module implements a progress upload ala Lighttpd mod_uploadprogress
for nginx. It monitors RFC1867 uploads sent to upstream servers and can
serve special JSON response containing information about the upload
progress on request.
This module doesn't implement a RFC1867 parser and client code. As such
I consider this module as a temporary hack until Igor Sysoev implements
a full client body filter chain into Nginx.
This module is delivered as is (no guarantee of any kind) under the BSD
license with the following caveats and warnings:
* this software has never been tested under load. It only passed a few
lab tests.
* it is not intended to be deployed on *production systems*.
* when compiled with --with-debug, this module will produce high number
of log messages.
More information on the wiki page I just created:
http://wiki.codemongers.com/NginxHttpUploadProgressModule
The code is available as an attachment of the aforementionned page.
Installation instructions:
nginx_uploadprogress_module has been compiled/tested with Nginx 0.6.1,
0.6.12 and 0.6.13.
1) download the Nginx sources from http://nginx.net/ and unpack it.
2) build Nginx: change to the directory which contains the Nginx
sources, and run the configuration script making sure to add the path
to the nginx_uploadprogress_module sources using the --add-module
option:
$ ./configure --add-module=/path/to/nginx_uploadprogress_module/
Now you can build and install the software:
$ make
and as root:
$ make install
For usage, configuration and examples, please see the wiki page or the
README file.
There are still some missing functionnalities, like retaining
information about a finished upload for a few seconds to be able to
serve to report upload request that the upload has finished...
Anyway enjoy :-)
--
Brice Figureau <brice+nginx(a)daysofwonder.com>
Hello all,
I have finally came around to publishing my git repository. You can
access it at http://git.localdomain.pl/
It currently isn't cloneable (I haven't set up a git-daemon, only
gitweb) -- I hope to enable it soon, if time permits.
You can find there all the patches (admittedly trivial) that we're
currently using. The main areas of interest are:
- CGI support (from nginx' side it's only a few rewrite flags for
workable PATH_INFO support, i.e. -F, -E and -X)
- security in a shared environment
- nested locations -- this is currently WIP.
Notes:
1. I'm only tracking the stable branch (0.5.x)
2. All the commits in `vanilla' branch are (of course) not mine. I
didn't bother to put the real author in there because the repo started
as an internal one, but if anybody finds this misleading or otherwise
unappropriate, please let me know and I'll change it.
3. All my code is based on my (limited) understanding of nginx
internals and comes without any warranty. That being said, we're using
it in production without problems. If you encounter any issues while
running our patched version, I'd be glad to hear about it.
4. The CGI+security patches have a performance impact due to many stat() calls.
5. The nested location support is grossly incomplete.
Best regards,
Grzegorz Nosek
Hey there nginxers-
Is there a way to use a geoip database with nginx instead of
explicitely listing out all the IP ranges in the nginx.conf?
Something like this:
http://www.maxmind.com/app/country
There is a modeul for apache and lighttpd for this type of stuff.
Any hints or help here? Or shoudl I just script something up to auto
generate the geoip config for nginx from one of these databases?
Thanks!
-- Ezra Zygmuntowicz
-- Founder & Ruby Hacker
-- ez(a)engineyard.com
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)
Hi,
I have nginx set up on 4 servers for a video streaming project but I have
drop out issues.
Server A is a simple proxy server that passes through the requests to the
backend box server B which holds the content.
Server C is another proxy that passes through requests to Server D which
houses the html, sql, php.
So while a user is on a page they video is passed to them from Server B
through Server A. The problem I have is that there have been reports of the
stream being cut after say 20 minutes or so (this time varies) and therefore
stopping the viewing of the video. I have experimented with different
settings but am having real difficulty finding anything that solves this
problem. Here is my proxy conf file:
user nginx nginx;
worker_processes 2;
pid logs/nginx.pid;
error_log logs/error.log warn;
events { worker_connections 1024; }
http {
include conf/mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
limit_zone one $binary_remote_addr 10m;
server {
limit_conn one 2;
listen 1.2.3.4:80;
server_name proxy.website.com;
location / {
proxy_pass http://1.2.3.4:8008/;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# client_max_body_size 10m;
# proxy_connect_timeout 90;
# proxy_send_timeout 90;
# proxy_read_timeout 90;
# proxy_temp_file_write_size 64k;
}
}
I would be most grateful any pointers anyone could give me. There is 100mbit
constant passing through this proxy btw.
Kind regards.
I would like to use nginx as an open proxy, using regular expressions to
get to any URL.
For example, if I browse through nginx through a URL like:
http://proxy.mydomain.com/hotmail.com
then nginx will proxy to http://hotmail.com
I tried working with the rewrite rule, but the best I could get was
getting it to try and serve me the file
/usr/local/nginx/html/http://hotmail.com.
Can it be done? Can someone steer me in the right direction?
Thanks,
Tony