Javascript nginx反向代理角度节点应用程序混合内容http请求

Javascript nginx反向代理角度节点应用程序混合内容http请求,javascript,node.js,express,ssl,nginx,Javascript,Node.js,Express,Ssl,Nginx,我正在处理nginx和node express server,该应用程序在端口80上使用反向代理时运行良好,但问题始于我在nginx上安装了带有certbot的SSL,我也尝试使用https节点模块,但当我从角度前端向节点后端发出请求时,仍然会出现混合内容错误。我认为nginx上的流量配置不好,也许我需要使用http设置从nginx到节点服务器(端口3000)的流量,但我不确定如何实现这一点。提前谢谢 请求时出现控制台错误: polyfills-es2015.aa82454585d558e175

我正在处理nginx和node express server,该应用程序在端口80上使用反向代理时运行良好,但问题始于我在nginx上安装了带有certbot的SSL,我也尝试使用https节点模块,但当我从角度前端向节点后端发出请求时,仍然会出现混合内容错误。我认为nginx上的流量配置不好,也许我需要使用http设置从nginx到节点服务器(端口3000)的流量,但我不确定如何实现这一点。提前谢谢

请求时出现控制台错误:

polyfills-es2015.aa82454585d558e1759e.js:1混合内容:页面位于'https://www.example.com/signup'已通过HTTPS加载,但请求了不安全的XMLHttpRequest终结点'http://23.91.62.176:3000/api/register'. 此请求已被阻止;内容必须通过HTTPS提供

这是我的nginx套装:

server {

   server_name example.com www.example.com;

    location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
  }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    if ($host = www.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name example.com www.example.com;
    return 404; # managed by Certbot

}
我的express服务器:

const express = require('express');
const cors = require('cors');

let app = express();

//routes
const user_routes = require('./routes/user.router');

// middlewares
app.use(cors());

app.use(('/'), express.static('client', {redirect: false}));
app.use('/api', user_routes);

app.get('*', function(req, res, next){
    res.sendFile(path.resolve('client/index.html'));
})


// start server
app.listen(3000, () => console.log('Server started at port : 3000'));
角度服务:

从'@angular/common/http'导入{HttpClient,HttpHeaders};
noAuthHeader={headers:newhttpheaders({'NoAuth':'True'})};
构造函数(私有http:HttpClient){}
姿势(用户:用户){
返回此.http.post('http://localhost:3000/api“+”/register',user,this.noAuthHeader);

}
我认为nginx的流量配置不好
。。。不,错误在网页本身-你唯一没有显示的东西。。。在某个地方,您试图通过
http
请求资源,这在加载页面
https
时是禁止的-正如错误所述。。。注意
proxy\u passhttp://localhost:3000;很好,不是错误的来源谢谢你的回答。该网页可以在浏览器上正常工作,使用我的vps ip和端口3000直接连接,http请求也可以工作。问题是当我进入我的域时,页面会加载,但会抛出混合内容错误。是的。。。因为如果您使用https加载页面,那么就不能将http用于其他资源/请求。我添加了y节点片段,我了解到可以通过http从前端到后端进行内部服务器通信,但我不确定您的页面是否使用https,然后
this.http.post(http://localhost:3000/api
将失败-将其更改为
this.http.post(https://localhost:3000/api
(我第三次说过同样的话)