nginx配置前后端的https

user  root;
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;

server {
    listen       80;
    server_name  ip;
      return 301 https://$http_host$request_uri;
}
server {
    listen 443 ssl;
    server_name  ip;
    ssl_certificate tc.cer;
         ssl_certificate_key  tc.key;

    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;


    location / {

            root    /home/vue/dist;
                index index.html;
             try_files $uri $uri/ /index.html;

    }
location @router {
       rewrite ^.*$ /index.html last;
}




    location  ^~ /api {

                  proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port $server_port;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
                proxy_pass http://ip:8081;
        }


}
}


你可能感兴趣的:(nginx,https,运维)