我正在尝试在AWS中加载平衡前端(公共)和后端(私有)服务器。我让nginx文件使用带有IP地址的单个服务器,但是loadbalancer DNS名称似乎不起作用,下面是我的前端服务器的nginx.conf。在负载均衡器的监听器部分,负载均衡器端口是443,实例端口是9000.任何建议都非常赞赏。
... WORKING
server {
listen 80;
rewrite ^(.*) https://example.com$request_uri;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/chain.crt;
ssl_certificate_key /etc/ssl/key.crt;
listen localhost:443;
server_tokens off;
client_max_body_size 300M;
location / {
root /var/www/html;
index index.html index.htm;
}
location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass https://<BackendIP>:9000/api/;
proxy_set_header Host $http_host;
}
}
}
不工作......
server {
listen 80;
rewrite ^(.*) https://example.com$request_uri;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/chain.crt;
ssl_certificate_key /etc/ssl/key.crt;
listen localhost:443;
server_tokens off;
client_max_body_size 300M;
location / {
root /var/www/html;
index index.html index.htm;
}
location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass https://<LOADBALANCER-DNS>:9000/api/;
proxy_set_header Host $http_host;
}
}
}