我在DigitalOcean Droplet上运行了两个网站,现在我已经在这两个网站上升级到了https。在其中一个网站上,我正在向节点服务器发出请求,我正在那里发送电子邮件,但是由于我启用了https,它会阻止此请求,因为它不是https(逻辑上)。所以我尝试使用节点邮件服务器作为其中一个启用了https的站点的代理传递。
要进行测试,我想要代理传递的节点服务器如下所示:
exports.start = () => {
app.use(bodyParser.json());
app.use(cors());
app.get('/', (req, res) => res.send('Hello World!'));
app.listen(4004, () => console.log('Server listening on port 4004'));
};
this.start();
我的Nginx sites-enabled/default
看起来像这样:
server {
server_name mywebsite.nl www.website.nl;
location / {
proxy_pass http://<PIVATE IP>:4000;
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;
}
location /ws {
proxy_pass http://<PIVATE IP>:4002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
}
location /mailmeister {
proxy_pass http://<PIVATE IP>:4004;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mywebsite.nl/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mywebsite.nl/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
}
因此/mailmeister
是我想将所有请求重定向到节点服务器的地方。
当我运行curl localhost:4004
或curl PRIVATE IP:4004
时,我得到了预期的结果
Hello World!
回复。但是当我运行curl https://mywebsite.nl/mailmeister
时,它会返回一个显示
Cannot GET /mailmeister
任何人都知道如何解决这个问题?