【发布时间】:2020-06-28 12:44:36
【问题描述】:
我已将 nginx 配置为服务器上的反向代理和负载平衡器,而另一台服务器上正在运行 Web 应用程序。当我访问 nginx 的公共 URL 时,它会显示 RHEL 的默认页面,而不是远程服务器上应用程序的主页。此外,当我在 nginx IP 中添加路径时,它会将我重定向到浏览器中应用程序服务器的 IP,而不是同一个 nginx 服务器。我希望IP与nginx服务器相同。
例子:
Nginx IP : 52.2.2.2
Remote Ip : 52.2.2.3
Browser
http://52.2.2.2/admin_portal
IP changes in Broswer
http://52.2.2.3/admin_portal
以下是我的配置: /etc/nginx/conf.d/load_balancer.conf
upstream backend {
server 10.128.0.2;
}
# This server accepts all traffic to port 80 and passes it to the upstream.
# Notice that the upstream name and the proxy_pass need to match.
server {
listen 80;
listen [::]:80;
location / {
proxy_pass http://backend;
}
}
我的 Nginx 配置文件 /etc/nginx/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
谁能帮帮我
【问题讨论】:
标签: linux nginx load-balancing reverse-proxy devops