配置nginx.conf文件,這個文件一般在/etc/nginx/...中,由于每個人的體質不一樣,也有可能在別的路徑里,自己找找...
# 配置工作進程的最大連接數
events {
worker_connections 1024;
}
# 配置HTTP服務
http {
# 導入mime.types配置文件
include mime.types;
# 設置默認的MIME類型為application/octet-stream
default_type application/octet-stream;
# 配置HTTP協議,如果訪問的端口為80,即HTTP協議,則跳轉到HTTPS協議
server {
# 監(jiān)聽端口80
listen 80;
# 配置域名
server_name www.feixxx.com feixxx.com;
# 重定向到HTTPS協議
rewrite ^(.*)$ https://$host$1 permanent;
}
# 配置HTTPS協議
server {
# 監(jiān)聽默認的HTTPS端口
listen 443 ssl;
# 配置域名
server_name feixxx.com;
# 配置SSL證書路徑,如下圖
ssl_certificate cert/www.feixxx.com.pem;
# 配置SSL證書的私鑰路徑,如下圖
ssl_certificate_key cert/www.feixxx.com.key;
# 配置SSL會話緩存
ssl_session_cache shared:SSL:1m;
# 配置SSL會話超時時間
ssl_session_timeout 5m;
# 設置服務器端密碼套件優(yōu)先
ssl_prefer_server_ciphers on;
# 設置默認的索引文件
index index.html;
# Vue項目存放路徑
root /www/wwwroot/vue/html;
location / {
# 嘗試匹配URL路徑,如果找不到對應的文件,則重定向到index.html
try_files $uri $uri/ /index.html;
}
#當請求中包含"/map"路徑時,將請求轉發(fā)到"https://feixxx.com:8088"這個地址上
location /map {
# 反向代理到https://feixxx.com:8088
proxy_pass https://feixxx.com:8088;
# 添加反向代理的請求頭,并隱藏響應頭中的X-Powered-By字段
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Powered-By;
}
#當請求中包含"/image"路徑時,將請求轉發(fā)到"https://feixxx.com:8088"這個地址上
location /image {
# 反向代理到https://feixxx.com:8088
proxy_pass https://feixxx.com:8088;
# 添加反向代理的請求頭,并隱藏響應頭中的X-Powered-By字段
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Powered-By;
}
#當請求中包含"/feedback"路徑時,將請求轉發(fā)到"https://feixxx.com:8088"這個地址上
location /feedback {
# 反向代理到https://feixxx.com:8088
proxy_pass https://feixxx.com:8088;
# 添加反向代理的請求頭,并隱藏響應頭中的X-Powered-By字段
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Powered-By;
}
}
}
證書存放位置,可自定義存放位置
兩個文件
后端配置
把.pfx拷貝到resource下,然后配置一下yml文章來源:http://www.zghlxwxcb.cn/news/detail-787906.html
ssl:
key-store: www.feixxx.com.pfx # pfk存放路徑
key-store-type: PKCS12 # tomcat服務器類型默認
key-store-password: htg72rfy # txt密碼粘貼即可
文章來源地址http://www.zghlxwxcb.cn/news/detail-787906.html
到了這里,關于SpringBoot + Vue2項目打包部署到服務器后,使用Nginx配置SSL證書,配置訪問HTTP協議轉HTTPS協議的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!