Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

How to configure nginx to listen for plain HTTP but proxy_pass to HTTPS address?

$
0
0
How to configure nginx to listen for plain HTTP but proxy_pass to HTTPS address?

In my Nginx config file, this is my preconfigured file content:

```
...
http {
...
server {
listen 8080 default_server;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name example.com www.example.com;
root /usr/share/nginx/html;

ssl_certificate "/etc/nginx/cert/example.com/combined.crt";
ssl_certificate_key "/etc/nginx/cert/example.com/private.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers PROFILE=SYSTEM;
ssl_prefer_server_ciphers on;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass https://13.215.8.22;
}

proxy_intercept_errors on;
error_page 404 /404.html;
location = /404.html {
root /etc/nginx/;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /etc/nginx/;
}
}
}
```
This configures listening on 8080 port and redirecting to 443 port for over SSL to origin server (proxy_pass) and works fine.

But, however, in my this scenario:
```
browser ---[apache:80/443 --- nginx(reverse-porxy):8080] --- origin server:443,

apache: listen 80/443
nginx: listen 8080
origin server: listen 443
```

I want nginx listen a plain HTTP port (8080), but as a client over SSL to connect origin server. In the node, there is Apache listening on 443, so I don't want assign additional SSL port for nginx.

In my scenario, how to setup the configuration file?

---

**EDIT-01**

I mean, I am looking for a way of configuring the nginx.conf
it just listen 8080 for HTTP request and as a *client* over SSL of origin HTTPS server. so my nginx only listen 8080 one port. whether this is viable?

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>