No certificate at hand, how to proxy https? NGINX TCP Forwarding

Source: Internet
Author: User

An overseas top-up Interface (HTTPS) on the line is often interrupted by my network problem, I want to use HK's machine to do an HTTPS reverse proxy and no certificate.

At first

At first, the idea was to proxy with Nginx TCP forwarding:

Add --with-stream option when compiling Nginx,

upstream backend {   server xxxxxx.com:443 ;}server {    listen 443;    proxy_pass backend;    proxy_connect_timeout 15s;    proxy_timeout 15s;    proxy_next_upstream_timeout 15s;   error_log /data/logs/tcp_xxxxxx.com.log info;}

The server does OK by binding host, transferring https://xxxxxx.com access requests to medium and reverse to the actual overseas server

However, there will also be a problem: 443 port can only be https://xxxxxx.com occupied, can not give other domain name agent to provide role

Later

What if I want https://xxxxxx.com and https://yyyyyy.com to use this machine agent? Nginx's stream_ssl_preread_module can solve this problem.

NGINX (1.11+), compile-time join:--with-stream and --with-stream_ssl_preread_module two options,

Then configure:

map $ssl_preread_server_name $backend_pool {    xxxxxx.com    xxx;    yyyyyy.com    yyy;}upstream xxx{    server xxxxxx.com :443;}upstream yyy{    server yyyyyy.com:443;}server {    listen 443;    ssl_preread on;    resolver 8.8.8.8;    proxy_pass $backend_pool;    proxy_connect_timeout 15s;    proxy_timeout 15s;    proxy_next_upstream_timeout 15s;    error_log /data/logs/tcp_xxxxxx-yyyyyy.com.log info;}

This can give https://xxxxxx.com and https://yyyyyy.com two domain name to do TCP layer proxy, other domain name if also bind host come over will be 403 off.

Here is actually the use of Nginx TCP forwarding made SNI anti-generation, and ordinary http/http difference is that TCP forwarding is only four-layer forwarding does not require a certificate:

    • SNI anti-generation: TCP Mirrored Stream replication
    • Normal HTTPS reverse: need to hang a certificate two times plus decrypt

In the case of many companies with internal and external network isolation, some development tools of intranet developers need to access the HTTPS Mirror warehouse site (for example: Gradle Plugin), you can use SNI reverse implementation

Reference: http://nginx.org/en/docs/stream/ngx_stream_ssl_preread_module.html

No certificate at hand, how to proxy https? NGINX TCP Forwarding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.