报李皆知待影几懂 2022-05-15 16:22 采纳率: 80%
浏览 52
已结题

http换成https时出现的问题

问题遇到的现象和发生背景

uwsgi+nginx+vue
原http协议换成https协议出现问题

还有跨域问题(咋配置)

img

img

uwsgi.ini

[uwsgi]
uid=mlh
socket=192.168.134.128:8000
chdir=/home/mlh/run_sth/water_quality_gradution
module=wsgi.py
home=/home/mlh/run_sth/water_quality_gradution/venv
wsgi-file=water_quality/wsgi.py
process=3
thread=3
# daemonize=uwsgi.log
pidfile=uwsgiPid.log
master=True
buffer-size=65536
disable-logging=false
enable-threads=true
thunder-lock=true
protocol=http

nginx.conf

    server {
        listen       443 default ssl;
        ssl On;
        ssl_certificate 7775973_www.mlhtest.xyz.pem;
        ssl_certificate_key 7775973_www.mlhtest.xyz.key;
         server_name www.mlhtest.xyz;
         location /dist/ {
        root /home/mlh/run_sth/water-quality-web;         
         }
    location / {
     proxy_pass         http://apiserver;
            proxy_set_header   Host $host;
        }    
    }
    server {
          listen 80;
          server_name  www.mlhtest.xyz;
          location / {
              rewrite ^(.*) https://$server_name$1 redirect;
          }
      }
问题相关代码,请勿粘贴截图

跨域,到底该怎么配置,crazy!

运行结果及报错内容
我想要达到的结果

原http替换为https且正常运行

  • 写回答

5条回答 默认 最新

  • 报李皆知待影几懂 2022-05-15 16:37
    关注

    nginx配置不熟悉,网络请求原理不懂,跨域概念模糊,难以下手。
    我q 2698298656,在线等大佬调教。

    跨域解决。但解决的方法辣眼睛

    img

    worker_processes  2; # 启动两个Nginx worker 进程
    events {
        # 每个工作进程 可以同时接收 1024 个连接
        worker_connections  1024; 
    }
    
    # 配置 Nginx worker 进程 最大允许 2000个网络连接
    worker_rlimit_nofile 2000;
    http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  30;
        gzip  on;
           # 配置 HTTP 服务器信息
        server {
            # 配置网站的域名,这里请改为你申请的域名, 如果没有域名,使用IP地址。
                rewrite ^(.*)$ https://$host$1 permanent;
        }
        server { 
            listen 443 ssl; 
            server_name  www.mlhtest.xyz;
            ssl_certificate 7775973_www.mlhtest.xyz.pem;
            ssl_certificate_key 7775973_www.mlhtest.xyz.key;
            location / { 
        uwsgi_pass 127.0.0.1:8000;
        include /etc/nginx/uwsgi_params;
        }
        location /dist/ {
            root /home/mlh/run_sth/water-quality-web;         
             }
    
    }
    
    }
    

    更改为https协议后:was loaded over HTTPS, but requested an insecure错误解决
    https://blog.csdn.net/weixin_40918067/article/details/117839199

    评论 编辑记录

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 5月16日
  • 修改了问题 5月16日
  • 修改了问题 5月16日
  • 创建了问题 5月15日

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘