使用Nginx配置SSL证书部署SpringBoot+Vue

贴一下nginx.conf配置文件

root是你vue工程build后的dist文件夹地址,直接把你的vue工程里面dist文件路径贴上去就行

server {
      listen  443;
      server_name  me.guanacossj.com;
      ssl on;
	    ssl_certificate   /etc/nginx/cert/xxx.pem;     # 路径/pem文件
	    ssl_certificate_key  /etc/nginx/cert/xxx.key;  # 路径/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;
      index index.html;
      root /home/MyBlog/myblogfront/dist;

      location /yunprophet {
        proxy_pass http://127.0.0.1:8085/yunprophet;
        proxy_read_timeout 300;
        proxy_connect_timeout 300;
        proxy_redirect     off;
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host              $http_host;
        proxy_set_header   X-Real-IP         $remote_addr;
      }
  }

这里443端口,也就是xxx.com后面是vue生成的静态文件,xxx.com/yunprophet/指向了springboot的后端

这里强调一点,springboot配置文件里一定要加这个

application.properties

server.servlet.context-path=/yunprophet

使得springboot默认访问地址从http://127.0.0.1:端口号/变成http://127.0.0.1:端口号/yunprophet

你可能感兴趣的:(java,springboot)