nginx配置http和https包含证书

nginx配置http和https如下:

 

 

 

    
     server {
     #同时监听80和443
        listen       80;
        listen       443 ssl;
        #域名
        server_name  cont.xxx.com;
        
        #证书路径
        ssl_certificate     D:/nginx-1.22.1/conf/ssl/cont.xxx.com.crt; 
        ssl_certificate_key  D:/nginx-1.22.1/conf/ssl/cont.xxx.com.key;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index index.html ;
            try_files $uri $uri/ /index.html;
        }
        
        #跨域请求代理配置
        location /prod-api/ {
            #重写以/api为baseURL的接口地址(本人的请求接口前面都是有加/api的)
            rewrite ^/prod-api/(.*) /$1 break;
            #需要代理访问的服务器地址
            proxy_pass http://127.0.0.1:8200;
        }

 

posted @ 2022-11-16 14:40  一个土豆一棵青菜  阅读(481)  评论(0编辑  收藏  举报