Kubernetes 上的 Nginx(99:无法分配请求的地址)
Nginx on Kubernetes (99: Cannot assign requested address)
所以我有我的应用程序的服务,并希望 nginx 代理到它的连接。我使用 IP 地址告诉 nginx 这是应用程序的服务节点端口 (100.68.202.75)。问题是当 pods 启动时它给我:
2019/05/25 17:32:38 [emerg] 1#1:bind() 到 100.71.178.70:443 失败(99:无法分配请求的地址)
nginx:[emerg] bind() 到 100.71.178.70:443 失败(99:无法分配请求的地址)
应用程序在具有服务的不同部署上单独运行。我只想告诉听那项服务。所以它可以重定向流量。
upstream so5098.exampler.com {
server 100.68.202.75:8080;
}
server {
listen 80;
server_name so5098.exampler.com masterqa-okta.exampler.com masterqapayrolltestingping.exampler.com;
rewrite ^(.*) https://$host permanent;
}
server {
listen 100.68.202.75:443;
ssl on;
ssl_certificate /home/xenon/.ssl/exampler.com.crt;
ssl_certificate_key /home/xenon/.ssl/exampler.com.key;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers 'TLS_RSA_WITH_AES_256_CBC_SHA256:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:AES256-SHA256:AES128+EECDH:AES128+EDH:!aNULL';
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
server_name masterqa.exampler.com masterqa-okta.exampler.com masterqapayrolltestingping.exampler.com;
# Upload file size limit
client_max_body_size 50m;
# bypass tomcat for profile images
location ~* /masterqa/profile/[0-9]*/.*\.(jpg|jpeg|gif|png)$ {
root /opt/documents/so5098/;
rewrite /opt/documents/saintssecurity/docs/([0-9]*)/(.*) // break;
}
# bypass tomcat for company logos
location ~* /so5098/logo/[0-9]*/.*\.(jpg|jpeg|gif|png)$ {
root /opt/example/docs-branch/;
rewrite /so5098/logo/([0-9]*)/(.*) // break;
}
# bypass tomcat for company theme
location ~* /masterqa/companyTheme/theme/[0-9]+_.*\.css$ {
root /opt/documents/so5098;
rewrite /masterqa/companyTheme/theme/([0-9]*)_.*.css //.css break;
}
location /so5098 {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://100.68.202.75:8080/so5098;
proxy_redirect http://$host https://$host;
}
location /so5098/api {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/masterqa/api;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://100.68.202.75:8080/so5098;
}
}
您应该将 listen 100.68.202.75:443;
替换为 listen 443 ssl;
。 Pod IP 是动态的,每次重新启动时都会更改。
所以我有我的应用程序的服务,并希望 nginx 代理到它的连接。我使用 IP 地址告诉 nginx 这是应用程序的服务节点端口 (100.68.202.75)。问题是当 pods 启动时它给我:
2019/05/25 17:32:38 [emerg] 1#1:bind() 到 100.71.178.70:443 失败(99:无法分配请求的地址) nginx:[emerg] bind() 到 100.71.178.70:443 失败(99:无法分配请求的地址)
应用程序在具有服务的不同部署上单独运行。我只想告诉听那项服务。所以它可以重定向流量。
upstream so5098.exampler.com {
server 100.68.202.75:8080;
}
server {
listen 80;
server_name so5098.exampler.com masterqa-okta.exampler.com masterqapayrolltestingping.exampler.com;
rewrite ^(.*) https://$host permanent;
}
server {
listen 100.68.202.75:443;
ssl on;
ssl_certificate /home/xenon/.ssl/exampler.com.crt;
ssl_certificate_key /home/xenon/.ssl/exampler.com.key;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers 'TLS_RSA_WITH_AES_256_CBC_SHA256:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:AES256-SHA256:AES128+EECDH:AES128+EDH:!aNULL';
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
server_name masterqa.exampler.com masterqa-okta.exampler.com masterqapayrolltestingping.exampler.com;
# Upload file size limit
client_max_body_size 50m;
# bypass tomcat for profile images
location ~* /masterqa/profile/[0-9]*/.*\.(jpg|jpeg|gif|png)$ {
root /opt/documents/so5098/;
rewrite /opt/documents/saintssecurity/docs/([0-9]*)/(.*) // break;
}
# bypass tomcat for company logos
location ~* /so5098/logo/[0-9]*/.*\.(jpg|jpeg|gif|png)$ {
root /opt/example/docs-branch/;
rewrite /so5098/logo/([0-9]*)/(.*) // break;
}
# bypass tomcat for company theme
location ~* /masterqa/companyTheme/theme/[0-9]+_.*\.css$ {
root /opt/documents/so5098;
rewrite /masterqa/companyTheme/theme/([0-9]*)_.*.css //.css break;
}
location /so5098 {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://100.68.202.75:8080/so5098;
proxy_redirect http://$host https://$host;
}
location /so5098/api {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/masterqa/api;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://100.68.202.75:8080/so5098;
}
}
您应该将 listen 100.68.202.75:443;
替换为 listen 443 ssl;
。 Pod IP 是动态的,每次重新启动时都会更改。