Https访问一个Nginx转向另一个内网Nginx

2022-09-28  本文已影响0人  李小二的倔强

配置文件内容

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information

    gzip  on;
    gzip_min_length 1k;
    gzip_comp_level 5;
    gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
    gzip_disable "MSIE [1-6]\.";
    gzip_vary on;

    client_max_body_size 2m;

    server {
        listen 80;
        server_name *.opendatachain.cn;
        rewrite ^(.*)$ https://$host$1 permanent;
    }

    server {
        listen       443 ssl http2;
        listen       [::]:443 ssl http2;
        server_name  *.opendatachain.cn;
        client_max_body_size 2m;
        location / {
            proxy_pass  http://10.0.85.163:80;
 #           proxy_pass  http://10.0.82.78:80;
            proxy_set_header X-Forwarded-Proto https;
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_redirect     off;
            proxy_connect_timeout      300;
            proxy_send_timeout         300;
            proxy_read_timeout         300;
            proxy_buffer_size          128k;
            proxy_buffers              8 64k;
            proxy_busy_buffers_size    128k;
            proxy_temp_file_write_size 128k;
        }

        ssl_certificate "/etc/nginx/opendatachain/cert.pem";
        ssl_certificate_key "/etc/nginx/opendatachain/key.pem";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM;
        ssl_prefer_server_ciphers on;

    }
    server {
        listen       443 ssl http2;
        listen       [::]:443 ssl http2;
        server_name  *.scichain.cn;
        client_max_body_size 2m;
        location / {
            proxy_pass  http://10.0.85.163:80;
 #           proxy_pass  http://10.0.82.78:80;
            proxy_set_header X-Forwarded-Proto https;
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_redirect     off;
            proxy_connect_timeout      300;
            proxy_send_timeout         300;
            proxy_read_timeout         300;
            proxy_buffer_size          128k;
            proxy_buffers              8 64k;
            proxy_busy_buffers_size    128k;
            proxy_temp_file_write_size 128k;
        }

        ssl_certificate "/etc/nginx/scichain/fullchain.cer";
        ssl_certificate_key "/etc/nginx/scichain/*.scichain.cn.key";

        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM;
        ssl_prefer_server_ciphers on;

    }
}

# include odc tcp config file
include stream.conf;

上一篇 下一篇

猜你喜欢

热点阅读