我已经在一台服务器上将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;
}有人能帮帮我吗?
发布于 2020-03-18 03:59:34
在传递代理之前,您必须重写它。
location / {
rewrite ^/reclaimed/Ip / last;
proxy_pass http://backend;
}https://stackoverflow.com/questions/60722327
复制相似问题