首页 > 解决方案 > 如何将 nginx.org 配置为渡槽服务器的代理服务器?

问题描述

我的渡槽服务器正在运行 ubuntu 18.04 ( http://127.0.0.1:8888 )。我从 nginx.org 安装 nginx。目前我在 nginx 上的渡槽没有使用任何块。我修改了默认配置,例如将我的域名添加到其中。我的渡槽服务器和 nginx 服务器都在单独工作。

我的问题是如何配置我的 nginx 以便我可以使用反向代理选项,这样我就不会直接连接到我的渡槽服务器。请问有什么帮助吗?

PS。我使用假域名和 ip 来显​​示我的配置设置。

我的 nginx 配置是:

# Default server configuration
# My domain (mobile.niyazitoros.com) ip: 5.5.5.5 // TEST IP
# ------ http://mobile.niyazitoros.com  and http://5.5.5.5  is working.

server {
    listen 80 default_server;
    listen [::]:80 default_server;

       server_name mobile.niyazitoros.com;

#    root /var/www/example.com;
#    index index.html;

    location / {
# My aqueduct server works on 127.0.0.1:8888
               proxy_pass http://127.0.0.1:8888/;
    }
}

标签: nginxdartreverse-proxyaqueduct

解决方案


好的。我找到了。我在站点可用和站点启用中使用 default.conf。这是修改 default.conf 的错误位置。正确的路径是修改 conf.d 目录中的 default.conf。

1)安装nginx 2)运行:nginx -v
(nginx版本:nginx/1.15.5) 3)sudo nano /etc/nginx/conf.d/default.conf

server {
    listen 80;
        listen [::]:80;

        error_log    /var/log/nginx/your_domain_name.error.log debug;
        rewrite_log on;

        server_name your_domain_name;

        location / {
                proxy_pass http://127.0.0.1:8888/;
    }
}

4) sudo systemctl reload nginx 5) sudo systemctl restart nginx 6) sudo nginx -t 7) curl http://your_domain_name/


推荐阅读