[常用软件] Nginx反向代理制作HTTPS

4061 0
noke 2021-8-20 13:47:14 | 显示全部楼层 |阅读模式

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  转发的域名;
                #rewrite ^(.*) https://$host$1 permanent;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;       
        location / {
            root   html;
            index   index.html index.htm;
                        proxy_pass 需要转发的地址:端口号;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
                #rewrite ^(.*) https://$host$1 permanent;                       
    }
         server {
        listen       80;
        server_name  转发的域名;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index   index.html index.htm;
                        proxy_pass http://127.0.0.1:8088;
        }


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
                #rewrite ^(.*) https://$host$2 permanent;       
    }


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
                #rewrite ^(.*) https://$host$2 permanent;       
    }

        #noke ---- FRP
         server {
        listen       80;
        server_name  域名;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index   index.html index.htm;
                        proxy_pass http://152.136.33.9:7500;
        }


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
                #rewrite ^(.*) https://$host$2 permanent;       
    }




             #HTTPS server
    #
     server {
        listen 443;
        server_name 域名; #填写绑定证书的域名
        ssl on;
        ssl_certificate ***-***-**.crt;     #数字证书的公钥文件
        ssl_certificate_key ***-***-**.key;        #数字证书的私钥文件
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
        ssl_prefer_server_ciphers on;
        location / {
            root   html; #站点目录
            index  index.html index.htm;   
                        proxy_pass http://152.136.33.9:8089;     #https指定的项目访问地址
        }
    }


        server {
        listen 443;
        server_name  域名; #填写绑定证书的域名
        ssl on;
        ssl_certificate ***-***-**.crt;     #第二个项目的公钥文件
        ssl_certificate_key ***-***-**.key;       #第二个项目的私钥文件
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
        ssl_prefer_server_ciphers on;
        location / {
            root   html; #站点目录
            index  index.html index.htm;
                        proxy_pass http://152.136.33.9:8088;       #第二个项目的指向项目访问地址
        }
    }
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}








您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

noke

初级红客

关注
  • 主题
  • 粉丝
  • 关注
这家伙很懒,什么都没留下!

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行