本文介绍了Nginx代理的mongo-express获取请求问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的ubuntu VPS上的 http://localhost:8081 上运行了mongo-express(mongodb管理界面).我想使用Nginx服务器代理它.

I have mongo-express(mongodb admin UI) running at http://localhost:8081 on my ubuntu VPS. I wan to proxy it using nginx sever.

这有效:/etc/nginx/sites-available/default

This works:/etc/nginx/sites-available/default

server {
    listen 80;
    server_name xyz.com;
    location / {
        proxy_pass http://localhost:8081;
    }
}

xyz.com->打开mongo-express管理页面.

xyz.com --> opens mongo-express admin page.

但这不是:(

server {
    listen 80;
    server_name xyz.com;
    location /mongoadmin {
        proxy_pass http://localhost:8081;
    }
}

更多详细信息:

xyz.com/mongoadmin->在Web浏览器中显示无法获取/mongoadmin/".

xyz.com/mongoadmin --> shows "Cannot GET /mongoadmin/" in web browser.

服务器上mongo-express上的调试日志也记录了GET请求(/mongoadmin/)

The debug log on mongo-express on server is also logging a GET request (/mongoadmin/)

推荐答案

尝试在这些行中添加斜杠:

Try to add slashes in these lines:

location /mongoadmin/ {
    proxy_pass http://localhost:8081/;
}

,以便该节点服务器将/mongoadmin之后的所有内容都视为根URL.

so that node server will treat everything after /mongoadmin as a root URL.

这篇关于Nginx代理的mongo-express获取请求问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 12:33