Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
21

You can use the errorfile directive and then a custom .http text file. So for example: errorfile 503 /etc/haproxy/errors/503-mycustom.http Content of the file would then be something like: HTTP/1.0 503 Service Unavailable Cache-Control: no-cache Connection: close Content-Type: text/html <html> <head> <title>RARRR!!!!!</title&...


19

Good news, with Version 1.3.15 http://mailman.nginx.org/pipermail/nginx/2013-March/038306.html we have the "limit_req_status" and "limit_conn_status" directives. I just tested them on Gentoo Linux (note that you need to have the modules limit_req and limit_con compiled in). With these settings I think you can achieve what you've asked for: ...


16

I have tried using check_http but I get success even if the website is redirected to an error page This can be solved with check_http --expect. Here is the documentation from check_http --help: -e, --expect=STRING Comma-delimited list of strings, at least one of them is expected in the first (status) line of the server response (default: HTTP/...


14

This looks perfectly normal to me. Most video (and even audio!) players request small chunks of the file at a time, and then request more later, as the user actually plays the video. 206 is only sent when the user-agent specifically requests a specific range of the file, rather than the entire file.


13

RFC 6066 doesn't specify or even recommend any particular HTTP error in the case that the hostname sent via SNI doesn't match the HTTP Host header. It does recommend that the server abort the TLS handshake if the SNI hostname is not one that it provides service for. From section 3: If the server understood the ClientHello extension but does not ...


7

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308 The RFC 7538 proposal have wide support today. It's safe. 308 instead 301. 307 instead 302. move != redirect Move reminds a specific address and/or file moved. Redirect is a new location or address.


7

Return codes that will be useful to the client. Bad authentication, 401. Bad request, 400. I'm a teapot, 418. See RFC 2616 for more information.


7

This was answered in another question: IIS7 Hijacks My Coldfusion Error Page Seems that the solution is changing the configuration so that IIS ignores the error and allows it to pass through, hence the setting <httpErrors existingResponse="PassThrough" /> So the solution is to change the behavior of IIS, which is fortunate, because requiring ...


6

There is something dirty you can do. You can block responses 503, which will result in returning the custom 502 error for which you can build an error page. However, keep in mind that any reason haproxy would have to return a 502 (invalid response) will return the same thing. Basically it's as simple as "rspdeny ^HTTP/1.1 503" combined with "errorfile 502".


5

We have a portion of our website running on a legacy system, and I ended up using the following: errorfile 502 /etc/haproxy/errors/502.http acl is_internal_error status ge 500 rspideny . if is_internal_error Hope it helps (even if it is 8 months later).


4

The 417 error should only occur when the client sent an HTTP Expect header that the server could not fulfill, which doesn't relate in any way to the application's "expected inputs" in the request. Do not use it. On the other hand, a 400 error should be sent only when there is bad syntax in the HTTP request that the server doesn't understand. Neither of ...


4

There are a series of error codes defined in RFC 2616 for HTTP 1.1 that cover the scenarios you mentioned. For example, in the case of improper authentication, you should probably return code 401 (Unauthorized). In the case of an invalid query string, you might return code 400 (Bad Request). Look at the RFC itself for the complete list along with some ...


4

Although 308 is now a standard (https://tools.ietf.org/html/rfc7538), it is not currently Safe [Edit] (as of 3 April 2019), especially for desktop applications, but may be almost safe in some specific regions (e.g. India), or for applications targeted at tablets and mobile devices. The lack of safety is because IE 11 on Windows 7 and 8.1 does not support it....


4

Your location / {}, containing a return 403; matches first. You should move it below two others. Happy leg shooting !


3

When a search engine spider founds 301 status code in response header of a webpage, it understand that this webpage is no longer exist, it searches for location header in response pick the new URL and replace the indexed URL with the new one and also transfer pagerank. So search engine refreshes all indexed URL that is no longer exist (301 found) with the ...


3

Basically you just change the HTTP_FORBIDDEN to HTTP_TOO_MANY_REQUESTS in mod_evasive20.c and compile again.


3

I would say that everything should send a valid host field except some bots and other automatic scanners. HTTP/1.0 (which did not have a hosts header) usage today is basically zero and again anything still using this is likely not something you want or need on your site. So to me there is limited value to 301 or 302ing these requests and they may end up ...


3

As joeqwerty said in a comment, nginx is correctly returning 200 because you asked for a document that exists. You would only get a 404 if you requested a document that does not exist. Try doing that instead. (And whether such a document exists on some other server is completely irrelevant.)


2

You can create more complex checks (in the spirit of Behavior Driven Development/Monitoring) with Cucumber-Nagios.


2

There is apparently a way to do this using Response.TrySkipIisCustomErrors. The below example is from an aspx page but should be adaptable to your use case. This following web content is too extensive to duplicate here. http://www.west-wind.com/weblog/posts/2009/Apr/29/IIS-7-Error-Pages-taking-over-500-Errors


2

It didn't send an HTTP version string (HTTP/1.1 or HTTP/1.0), that client is not speaking correct HTTP. It should most certainly get a 400 Bad Request response. See RFC 2616: The request could not be understood by the server due to malformed syntax.


2

I think it could work by defining a static ErrorDocument eg: ErrorDocument 400 /redirect_https.txt and create the file redirect_https.txt in your document root with the following content: HTTP/1.1 302 Found Location: https://myserver/mypage.html this works (even tried) and sends the browser a "faked" HTTP-redirect


2

If the parameters for a GET request are incorrect, the canonical thing to do is send back either a 404 (not found), or 200 (OK). The RESTful way to use GET requests is to query a resource (get something). Therefore, if the required parameters don't correspond to an extant resource (because they are incomplete), you can accurately say the resource as ...


2

I can't quite figure out what your doing however there is an additional option that you may not have considered - 200 - OK. The reason is that you received the data correctly the problem is it's not valid for your application which isn't really a problem with the HTTP protocol. The relevant rfc here is rfc2616. You could use 400 but you then need to ...


2

Set the document root to an otherwise empty directory, and use a dynamic error handler to send a 410 response. Example: $HTTP["host"] == "gone.example.com" { server.document-root = "/var/www/gone" server.error-handler-404 = "/gone.php" } Where /var/www/gone/gone.php contains something like the following: <?php header("HTTP/1.1 410 Gone"); header("...


2

Well, I'll answer myself on that one. The problem is not from NGinx but from the backend, here, PlayFramework that returns a 404 when a HEAD is requested and the routes files does not contains HEAD. A bug has been opened for that : https://github.com/playframework/playframework/issues/2280


2

Short answer: try this for your location block: location / { proxy_read_timeout 120; proxy_next_upstream error; proxy_pass http://$backend; } Longer explanation: I think I have just encountered exactly the problem you described: I use nginx reverse proxy as a load balancer for long-running requests, the backend receives the same request multiple ...


2

A 201 is Created not Accepted http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 10.2.2 201 Created The request has been fulfilled and resulted in a new resource being created. The newly created resource can be referenced by the URI(s) returned in the entity of the response, with the most specific URI for the resource given by a Location header ...


2

To end this: No it is not safe to use that status code. See comments for details. 308 is not a standard - it's a proposal, still in the experimental stage. Browers should fall back to a 300 interpretation of any 301-399 error that they don't specifically understand. Some browsers just fail completely on that status code.


2

Try to replace: error_page 404 uwsgi_pass unix:/tmp/uwsgi_myproject.sock;/errors/404 by: error_page 404 /errors/404; location /errors/ { uwsgi_intercept_errors on; include uwsgi_params; uwsgi_pass unix:/tmp/uwsgi_myproject.sock; } source: http://nginx.org/en/docs/http/ngx_http_uwsgi_module.html#uwsgi_intercept_errors


Only top voted, non community-wiki answers of a minimum length are eligible