nginx代理https 转发成http和websocket的配置

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_33048069/article/details/81905882

# 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 /var/run/nginx.pid;

# Load dynamic modules. See /usr/share/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 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
 upstream  https_Proxy {
     server    127.0.0.1:12150  weight=1;
}
   server {
        listen  20080 ssl so_keepalive=on;  
        #申请的域名
        server_name www.target.com; 

        #相应的SSL证书
        ssl_certificate "/home/cert/target.pem"; 
        ssl_certificate_key "/home/cert/target.key";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;
        
        location / {
        proxy_redirect off;
        #proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Remote_addr $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://https_Proxy;
        }

        error_page 404 /404.html;
            location = /40x.html {
       }
}
    

}
 

配置完之后,主要防火墙设置端口 

重启nginx

nginx -c 相应路径下的nginx.conf

猜你喜欢

转载自blog.csdn.net/qq_33048069/article/details/81905882
今日推荐