Hi, getting quite desperate at the moment about this.
I have a server serving several subdomains; actually proxying’em to
apache2. So I have main nginx vhost file with all server_name’s added.
Such server names match the defined ServerName’s and ServerAlias’es of
Apache.
Beside, I have one more file to define a default_server catch all block
like follows
server {
listen 80 default_server;
server_name _;
error_log /var/log/nginx/000default-error.log error;
root /var/www/forvo.com/_templates;
error_page 404 /404.html;
location / {
#return 444;
return 404;
}
location = /404.html {
internal;
}
#rewrite .* http://myfaultysubdomain.com permanent;
}
As soon as I enable this file, everything works as expected, however, in
less than one minute (my site is always being visited), all requests
(good subdomains and bad subdomains as well) start to get 503 response.
No log at all seems to change when this happens.
Any clue to what may be happening pleeeeeease …it’s been hours,
during days, trying to figure out what the h@$!! is going on
Posted at Nginx Forum:
On 24 Jan 2012 15h26 WET, [email protected] wrote:
server_name _;
#rewrite .* http://myfaultysubdomain.com permanent;
}
AFAICT there’s nothing here that should cause the 503s. Do you have
any limits set, be it connection or rate limit?
— appa
glubs !!! header host looks like “the missing culprit”, I’ll check it
out to confirm your nice guess Mit Rowe
Posted at Nginx Forum:
On 24 Jan 2012 17h57 WET, [email protected] wrote:
glubs !!! header host looks like “the missing culprit”, I’ll check
it out to confirm your nice guess Mit Rowe
444 closes the connection. Doesn’t return any 503 code.
— appa
we might need to see your whole configuration to get the full picture,
but
here’s an initial thought…
if your apache does virtual hosting based on the Host: header (which
seems
likely from your description), you may need to pass the Host: header
along,
which you can do like this:
proxy_set_header Host $http_host;
On Tue, Jan 24, 2012 at 10:33 AM, Antnio P. P. Almeida
[email protected]wrote:
server {
internal;
[email protected]
nginx Info Page
–
Will ‘Mit’ Rowe
Stagename*
*1-866-326-3098
[email protected] [email protected]
Twitter: @stagename
The information transmitted is intended only for the person or entity
to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of this
information by persons or entities other than the intended recipient is
prohibited. If you received this transmission in error, please contact
the
sender and delete all material contained herein from your computer.
António P. P. Almeida Wrote:
On 24 Jan 2012 17h57 WET, [email protected]
wrote:
glubs !!! header host looks like “the missing
culprit”, I’ll check
it out to confirm your nice guess Mit Rowe
444 closes the connection. Doesn’t return any 503
code.
I know i know …it’s commented out
— appa
nginx mailing list
[email protected]
nginx Info Page
Posted at Nginx Forum:
Ok as I started thinking later …what for do I need proxy_set_header
if my intention is to not proxy to Apache any request fall onto this
catch all default_server ?
To see my config let’s say it is as follow (not all parameters to let it
be clearer):
====================== /etc/nginx/sites-enabled/mydomain
server {
listen 80;
server_name mydomain.com www.mydomain.com sub1.mydomain.com
sub2.mydomain.com sub3.mydomain.com
error_page 502 503 504 400 /50x.html;
error_page 404 /404.php;
large_client_header_buffers 4 4k;
location = /50x.html {
root /var/www/mydomain/static/;
}
location ~* \.(jpg|jpeg|gif|png|css|bmp|ico|txt|html|swf)$ {
root /var/www/mydomain/
expires 1y;
}
location / {
proxy_pass http://127.0.0.1:60080/;
proxy_redirect off;
........
}
}
So my goal is to define a new vhost so that all requests reaching my
nginx which don’t fit any of my server names (all subdomains) are
responded as one of 2 :: 404 returned or forwarding to another external
URL (…whatever it fits better for SEO)
====================== /etc/nginx/sites-enabled/mydomain
server {
listen 80 default_server;
server_name _;
error_log /var/log/nginx/000default-error.log error;
location / {
proxy_set_header Host $host;
#return 404;
rewrite .* http://doesnotexist.com permanent;
}
}
I must say I tested (sure badly i did ) the proxy_set_header (not sure
what for in my case) and still the same behaviour …all my clients
away 
Posted at Nginx Forum:
On 25 Jan 2012 15h39 WET, [email protected] wrote:
listen 80;
location ~* .(jpg|jpeg|gif|png|css|bmp|ico|txt|html|swf)$ {
location / {
proxy_set_header Host $host;
#return 404;
rewrite .* http://doesnotexist.com permanent;
}
}
This can be made much simpler:
server {
listen 80 default_server;
server_name _;
error_log /var/log/nginx/000default-error.log error;
return 301 http://doesnotexist.com;
}
This redirects to a new host.
For returning a 404 just do:
return 404;
I think that 444 is preferable. No business trying to access a host
that doesn’t exist. But it’s up to you.
Enable the debug log and set:
proxy_intercept_errors on;
Trace the requests and see how are the 503s generated.
http://nginx.org/en/docs/debugging_log.html
— appa
Ok, first of all thanks a lot Antonio for your answer.
I’ve followed your instructions adding following block to the very
beggining of my only one nginx/site-enabled (in just one of my 2
balanced nginx):
server {
listen 80 default_server;
server_name _;
proxy_intercept_errors on;
error_log /var/log/nginx/000default-error.log debug;
access_log /var/log/nginx/000default-access.log;
return 444;
}
below this block came the 3 vhost I serve, all of them with plenty of
server_name’s.
More “clues” I surely shoud have given at my first post ::
.- Architecture :: AWS Elastic Load Balancer ====> 2 nginx each one
proxying to its own apache2
.- My php application relies a lot on apache redirects in htaccess of
the style: .*whatever/ .*whatever.php
.- As soon as i enable the above block, Server seems to respond Ok but
the 000default-access.log starts to be filled with:
…-[A] Plenty of requests responded with the 444 code
.- [B] Plenty of strange request like this :::
[01/Feb/2012:12:13:40 +0100] “-” 400 0 “-” “-”
.- In less than 3 minutes, suddenly the above access log stops receiving
that bunch of 444 responded requests[A] and it only shows the [B] from
time to time (some buffer overloaded?)
Just to say, the debug level and logs probably I did not use it well as
it is not adding actual extra info. should it be added to in the rest of
the server blocks below the default one?
like an X-File to me …don’t know what else to do or try
Posted at Nginx Forum:
At last I got it ! Well, to be honest I will say Maxim Dounim helped me
thru my logs. In the end it was so simple ::: My load balancer in front
of my Nginx’s always looked thru IP so no host name ever matched any of
my server_name’s. Solution simple :: Do the balancer refer to nodes thru
a locally resolved hostname also put as a new server_name.
…simple like crazyness when it comes.
The thing now is I have following block and it works quite right. But If
I mean to use the commented return 444 instead of the rewrite ==> al my
web start returning 503 !!! and nothing’s functioning …always the
strange things to me.
server {
listen 80 default_server;
server_name _;
error_log /var/log/nginx/000default-error.log error;
location / {
proxy_set_header Host $host;
rewrite .* http://somewherelse.net permanent;
#return 444;
}
}
Posted at Nginx Forum:
On 22 March 2012 16:32, lockev3.0 [email protected] wrote:
strange things to me.
}
Er, WTF?
You use the non-standard 444 (“444 closes the connection without
sending any headers”) and you expect your downstream to do something
with that other than correctly respond to requests with a 503
Service Unavailable?
What you describe is exactly what I’d expect to see.
Either your understanding/expectations are faulty, or you haven’t
explained yourself correctly.
Jonathan
please help
this bothering X-File is causing crawlers to index my site with plenty
of non-existent subdomains …
Posted at Nginx Forum:
Well, probably I’m, still novice at Nginx but, that default server block
is meant to fit when no other block server (server_name) fits. So my
current problem is that 444 behaviour is arising all thru my nginx
server, not just that default_server block/vhost
…not quit sure If I explained my self better now ? or even
understood you right …
Posted at Nginx Forum:
Hello!
On Mon, Apr 16, 2012 at 04:43:46AM -0400, lockev3.0 wrote:
Well, probably I’m, still novice at Nginx but, that default server block
is meant to fit when no other block server (server_name) fits. So my
current problem is that 444 behaviour is arising all thru my nginx
server, not just that default_server block/vhost
…not quit sure If I explained my self better now ? or even
understood you right …
I belive Jonathan M. is right and the problem is as follows:
your load balancer sees invalid response from your nginx server
(as “return 444” just drops the connection) and starts to think
it’s not working (and starts to return errors to clients without
even asking nginx).
There are two possible solutions:
-
Don’t use “return 444” but return some correct response. In
any case “return 444” doesn’t help at all as long as your nginx is
behind load balancer (as your balancer will return response
anyway).
-
Tune your balancer to ignore such connection closes (not sure
this is possible).
Maxim D.