I have an nginx proxy pointing at an external server. When the external server is down, the nginx proxy returns a 502 bad gateway.
Instead, I'd like nginx to also refuse the connection - How can I do this?
Related
I have an Ngins, deployed as a pod inside the Openshift cluster, acts as reverse proxy for a backend-service. The backend-service has Kubernetes service to loadbalance the traffic between the pods (we use ha proxy as loadbalancer). The Nginx pass_proxy all the request to the service.
location /service-1/api {
proxy_pass http://service-svc/api;
}
Anytime the Kubernetes service is recreated or it get a new IP address, the Nginx doesnt refresh the new address - this throws 504 timeout error. I tried the resolver of the Nginx with 127.0.0.1, 127.0.0.11 and other ways to force the Nginx refresh the dns lookup, along with assigning the service to a variable.
However, this doesn't solve the problem. The Nginx couldn't resolve the service, saying it cannot resolve using 127.0.0.1:53. What is the right way to put the resolver? What IP should I provide in the resolver?
I'm using Nginx as reverse proxy. With the directive proxy_intercept_errors I can intercept 50x errors from remote server and handle them. I'm looking for a way to handle a specific error only if was generated from my nginx reverse proxy, and not from the remote server. How can I do?
I have a Docker swarm running Docker version 1.13.1. I am regularly deploying stacks of Docker services (via docker stack deploy) to this swarm, and I have one nginx proxy service that sits at ports 80 and 443 acting as a reverse proxy to various applications in the swarm.
I ran into a problem with using nginx's upstream capability was that it cached the DNS lookup of my service names. This worked fine for a while but as more stacks were removed and deployed those cached IP addresses became stale and nginx would start timing out or serving requests to the wrong container.
I attempted to fix this using the following technique:
[in nginx.conf]
server {
server_name myapp.domain.com;
resolver 127.0.0.11 valid=10s ipv6=off;
set $myapp http://stack_myapp:80; # stack_myapp is the DNS name of the service
location / {
proxy_pass $myapp;
}
}
# other similar server blocks
127.0.0.11 appears to be the IP address of the internal DNS server the swarm sets up. This seems to work most of the time - the IP addresses of the upstream services do not get cached for long and the proxy recovers if upstream services move around. However, the proxy will occasionally still serve requests to incorrect addresses, for example, it will serve requests to http://10.0.0.12:80/... and time out or hit the wrong container. When I run docker exec proxycontainer ping stack_myapp, I get the correct IP address. Why is nginx not resolving the correct IP when ping does?
i've successfully managed to set up a reverse proxy which receives data via POST requests from clients and forwards them to a NodeJS server for further processing and storing.
now i would like the nginx reverse proxy to return a 200 OK blank response for all of these requests BEFORE forwarding to the nodeJS server. so the clients will receive the response immediately without the need to wait for the backend server to finish the processing.
if i use "return 202;" inside the location directive, the nginx reverse proxy does respond immediately, but never forwards the request to the NodeJS server.
can this be achieved with nginx?
any help would be much appreciated.
Thanks,
I have an 3 legged NGINX reverse proxy setup with External, Internal and DMZ networks.
NGINX has a reverse proxy server configured to listen on port 80 in the DMZ. I need to forward the request to another server via an upstream HTTP proxy, the request cannot be retrieved directly.
If I put the WEB proxy's IP address into upstream section - it sends "POST /DataService.svc HTTP/1.0" to http proxy and that obviously does not work.
Is it possible to rewrite $uri to include the host name in the request so it will look like "POST http://server.com/DataService.svc HTTP/1.0"
Should this work and how can I achieve this without installing squid etc...