Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
358 views
in Technique[技术] by (71.8m points)

Nginx将http转为https后的接口调用问题

内网环境的项目,要求用https,但是80端口和443端口都被禁用了。
项目开发用的是http,现在用Nginx将http转为https,前端已经能访问,可是调用后台接口就404了,请问各位大佬怎么解决这个问题?
ssl证书是用OpenSSL生成的。
环境是windows。

server {
        listen       9528 ssl;
        server_name  172.168.16.6;
        
        ssl_certificate C://Users//Desktop//ssl//server.crt;
        ssl_certificate_key C://Users//Desktop//ssl//server1.key;

        error_page 497 301 =307 https://172.168.16.6:9528$request_uri;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            try_files $uri $uri/ /index.html;
        }

    location /prod-api/{
        proxy_pass http://172.168.16.6:8201/;

        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        #proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Protocol $scheme;
    }

下面是错误日志的内容

2020/07/17 10:33:35 [error] 10416#9256: *11 connect() failed (
    10061: No connection could be made because the target machine actively refused it) while connecting to upstream, 
    client: 172.168.16.6, server: 172.168.16.6, 
    request: "GET /prod-api/login/code HTTP/1.1", 
    upstream: "http://172.168.16.6:80/login/code", 
    host: "172.168.16.6:9528", 
    referrer: "https://172.168.16.6:9528/login?redirect=%2Fdashboard"

2020/07/17 10:33:35 [error] 10416#9256: *11 CreateFile() "C:UsersDesktopssl
ginx-1.16.1/html/50x.html" failed (
    2: The system cannot find the file specified), 
    client: 172.168.16.6, 
    server: 172.168.16.6, 
    request: "GET /prod-api/login/code HTTP/1.1", 
    upstream: "http://172.168.16.6:80/login/code", 
    host: "172.168.16.6:9528", 
    referrer: "https://172.168.16.6:9528/login?redirect=%2Fdashboard"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...