美文网首页
关于nginx部署https前端项目 问题以及一些配置

关于nginx部署https前端项目 问题以及一些配置

作者: 无题syl | 来源:发表于2023-08-28 19:11 被阅读0次

http改成https环境

目前是 前端项目路径是 https 这个需要配置nginx.conf 加上证书 后面后给出详细配置文件
访问后台的接口也是 改成https (这个需要后台java生成自签证书 利用jdk keystore)
然后nginx 配置文件代理 proxy也要改成https
在c++ qt中 把http 换成https 调用的ws 要换成wss 此时qt中也要结合证书

问题1:它们三个的证书应该可以使用同一个吧??

  1. 前端是https 然后nginx代理到原本http这样也是可以的吗??这样就不用这么麻烦了
  2. 当浏览器访问 qt wss时候会弹出不安全链接 此时 点击高级 继续即可
  3. 好像nginx 可以配置 避开wss证书验证?? 具体操作没测试 代理好像可以避开证书验证??
    5.nginx配置里好像有又好像没有写关于wss的代理 还是只是前台配置好然后打包仍进入就行

cert文件夹:主要是证书文件

server.crt 安全证书
server.csr csr文件
server.key key文件
server.pem pem文件
serve.pkcs12 文件

nginx配置:

server:{
listen  8026  ssl;
server_name: localhost;

ssl_certificate   server.crt;
ssl_certificate_key  server.key

ssl_session_cache  shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols TLSv1.2;

ssl_ciphers  HIGH:!aNULL:!MD5;
ssl_perfer_server_ciphers on;

location / {
root  /项目dist包所在地址
index index.html index.htm
try_files $uri #uri/ /index.html;
}

# 配置代理  FFFController 是请求地址其中一个字符串  可以使用别的方式代理
location ~/FFFController/ {
set  $allow_cors 0;

# 判断不为空
if($http_origin){
set $allow_cors 1;
}

# 判断不在白名单内
if ($http_origin !~*"(10.1.1.235)"){
set $allow_cors "${allow_cors}1"
}

#判断不为空 且 不在白名单内,返回403
if($allow_cors ="11"){
return 403;
}


add_header 'Access-Control-Allow-Origin' 'https://198.1.1.235:8023' always;
add_header 'Access-Control-Allow-Credentials'  'false' always;
proxy_pass https://198.1.1.235:8023
# 这里改成https
}


# wss配置 (不知道前端是不是通过这个代理访问wss的)

location /websocket/99 {
# 这个不知道是否换成https
proxy_pass http://198.29.30.99:8022;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header  Connection "upgrade"
}



}

相关文章

网友评论

      本文标题:关于nginx部署https前端项目 问题以及一些配置

      本文链接:https://www.haomeiwen.com/subject/wvogmdtx.html