nginx - 如何将 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/;
}
}
解决方案
好的。我找到了。我在站点可用和站点启用中使用 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/
推荐阅读
- zeebe - 如何在 1.1.0 稳定版的 zeebe 客户端中完成“USER_TASK”?
- mongodb - 连接完成后如何创建一个简单的检索 API?
- nginx - Nginx 从 proxy_pass 读取 django 响应的标头
- winforms - cefsharp winform 经常崩溃
- java - 使用 Scanner 函数获取用户输入
- python - 订阅图像主题但不输出图像
- android - 颤动中的图层模糊
- python - 如何在我的 python Azure 函数中安全地使用 TableService 对象?
- javascript - 羽毛图标未显示在 react-data-table-component 列中
- java - 使用 Java 流添加到现有地图