nginx reverse proxy to upstream via web proxy - nginx

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...

Related

SSL termination and proxy_pass

I have an Nginx proxy where I have over 200 sites available (all SSL). I would like to simplify the traffic and terminate the SSL in the proxy and re-encrypt with a single certificate all 200 possible hosts and proxy pass them upstream.
Is this even possible?

How to can http services from https server

I have apache server(Frontend code) running on 80 port with https secure(SSL is configured). Backend server is nodejs and it is configured on 3000 port. When I tried to call services from https to http i.e. Apache(port 80 ssl configured) to Nodejs (port 3000 non-ssl) it is giving showing failed with status as "net::ERR_SSL_PROTOCOL_ERROR".
This may have something to do with Same Origin policy.
Please see that answer: HTTP Ajax Request via HTTPS Page.

Redirect HTTPS request to HTTP (varnish) and then backend server HTTPS

My current configuration is like this :
1. Nginx listening on Port 8080 and 443
2. Varnish listening to port 80
Currently, when requests are made through HTTP they are delivered through the varnish, but when requests are made through HTTPS varnish doesn't deliver them.
My goal is to put varnish between Client and Nginx web server ( or make varnish work with port 443 )
Reading through articles and answer on StackOverflow, I tried to setup reverse proxy 443 to 80 ( or 8080 maybe ?)
I followed these article(s) :
https://www.smashingmagazine.com/2015/09/https-everywhere-with-nginx-varnish-apache/
https://serverfault.com/questions/835887/redirect-http-to-https-using-varnish-4-1
Problem is that when I try to set these up, I get 502 bad request error, and sometimes the default Nginx page.
PS: I'm trying to set this up using virtual server block, not default server.
PS2: I also need to deliver the final web page through HTTPS weather the request made through HTTP or HTTPS ( but I get too many redirects error )
PS3: I'm using Cloudflare
The basic concept is to sandwich varnish between an entity handling SSL and a back-end server working on port 8080 or whatever you choose.
Here's the traffic flow:
user 443 > front-end proxy for SSL offloading 443 > Varnish 80 > nginx 8080.
Now your options for Front end proxy are:
1.A Load balancer supporting SSL termination / offloading.
2.Nginx or apache working as a proxy to receive traffic on 443 and forward that on port 80 to Varnish.
Error 502 means your Varnish is having issues connecting your backend, please check varnish.vcl

Nginx route https as http

I have an nginx server which proxies requests to a service which works on https.
Nginx server is in the same private network with my services which use it.
Can I use http between my service and nginx or in this case nginx will not encrypt traffic between nginx and external service?
So I have:
MyService --privite network http request--> Nginx --https--> exteranl service.
server {
listen 8080;
location / {
proxy_pass https://example.com;
}
}
My concern is that I send http request and expect encrypted data somewhere along the way.
Will it realy work as Nginx --https--> external or it will be Nginx --http--> external?

how to make nginx proxy pass along connection refused?

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?

Resources