wso2 api manager 3.2.0 nginx 负载均衡无法访问此站点错误? [英] wso2 api manager 3.2.0 nginx load balancing this site can’t be reached error?

查看:44
本文介绍了wso2 api manager 3.2.0 nginx 负载均衡无法访问此站点错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Nginx 为 wso2 api manager 3.2.0 使用负载平衡.当在 nginx 服务器中调用 https://localhsot:443 时,它重定向到

Nginx 配置:

 用户 nginx;worker_processes 自动;事件{worker_connections 1024;}http {上游 sslapi.am.wso2.com {服务器 172.24.64.114:9443;服务器 172.24.64.114:9443;}上游 sslgw.am.wso2.com {服务器 172.24.64.114:8243;服务器 172.24.64.114:8243;}服务器 {听80;server_name api.am.wso2.com;重写 ^/(.*) https://api.am.wso2.com/$1 永久;}服务器 {听 443 ssl;server_name api.am.wso2.com;proxy_set_header X-Forwarded-Port 443;ssl_certificate/etc/nginx/ssl/apimanager.crt;ssl_certificate_key/etc/nginx/ssl/apimanager.key;地点/{proxy_set_header X-Forwarded-Host $host;proxy_set_header X-Forwarded-Server $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header 主机 $http_host;proxy_read_timeout 5m;proxy_send_timeout 5m;proxy_pass https://sslapi.am.wso2.com;}}服务器 {听 443 ssl;server_name gw.am.wso2.com;proxy_set_header X-Forwarded-Port 443;ssl_certificate/etc/nginx/ssl/apimanager.crt;ssl_certificate_key/etc/nginx/ssl/apimanager.key;地点/{proxy_set_header X-Forwarded-Host $host;proxy_set_header X-Forwarded-Server $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header 主机 $http_host;proxy_read_timeout 5m;proxy_send_timeout 5m;proxy_pass https://sslgw.am.wso2.com;}}}

和服务器中的 deployment.toml 配置(172.24.64.114):

[transport.https.properties]代理端口 = 443[服务器]主机名 = "api.am.wso2.com";node_ip = "172.24.64.114";#偏移=0模式=单"#single 或 habase_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}";#discard_empty_caches = falseserver_role =默认";

和主机配置(172.16.11.239)服务器:

172.0.0.1 本地主机172.24.64.114 api.am.wso2.com

和主机配置(172.24.64.114)服务器:

 172.24.64.114 api.am.wso2.com

调用 nginx url (172.24.64.116) 后,它重定向到 172.24.64.114,即站点无法访问!

解决方案

当您使用代理端口配置配置 API 管理器时,还需要指定主机名.需要在Nginx中server配置下配置相同的Hostname.此外,在 upstream 下,您必须配置 API Manager 节点的 IP 地址以引导请求.

由于您在中间有一个专用的 Nginx 服务器 (.116),请配置 Nginx 服务器的 IP 地址 (.116) 和 API 管理器的主机名 (api.am.wso2.com) 在客户端节点的 (.239) 主机条目中.这将确保当您在客户端节点中键入 Hostname: api.am.wso2.com 时,请求将被分派到 Nginx 服务器,然后 Nginx 将与上游进行通信已配置的服务器.

尝试在客户端节点中正确配置主机条目并验证行为.Client's Hosts 中的示例条目如下

172.24.64.116 api.am.wso2.com

I want to use loadbalancing for wso2 api manager 3.2.0 using Nginx. when call https://localhsot:443 in nginx server, it redirects to https://api.am.wso2.com/publisher, but can not reach this site error occurs. could you please me guide, what is wrong?

Nginx config:

  user  nginx;
worker_processes  auto;



events {
    worker_connections  1024;
}

http {

upstream sslapi.am.wso2.com {
    server 172.24.64.114:9443;
    server 172.24.64.114:9443;
}

upstream sslgw.am.wso2.com {
    server 172.24.64.114:8243;
    server 172.24.64.114:8243;
}

server {
    listen 80;
    server_name api.am.wso2.com;
    rewrite ^/(.*) https://api.am.wso2.com/$1 permanent;
}

server {
    listen 443 ssl;
    server_name api.am.wso2.com;
    proxy_set_header X-Forwarded-Port 443;
    ssl_certificate /etc/nginx/ssl/apimanager.crt;
    ssl_certificate_key /etc/nginx/ssl/apimanager.key;
    location / {
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_read_timeout 5m;
            proxy_send_timeout 5m;
            proxy_pass https://sslapi.am.wso2.com;
        }

}

server {
    listen 443 ssl;
    server_name gw.am.wso2.com;
    proxy_set_header X-Forwarded-Port 443;
    ssl_certificate /etc/nginx/ssl/apimanager.crt;
    ssl_certificate_key /etc/nginx/ssl/apimanager.key;
    location / {
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_read_timeout 5m;
            proxy_send_timeout 5m;
            proxy_pass https://sslgw.am.wso2.com;
        }

}

}

and deployment.toml config in server(172.24.64.114):

[transport.https.properties]
proxyPort = 443

[server]
hostname = "api.am.wso2.com"

node_ip = "172.24.64.114"
#offset=0
mode = "single" #single or ha
base_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}"
#discard_empty_caches = false
server_role = "default"

and hosts config in (172.16.11.239) server:

172.0.0.1 localhost
172.24.64.114 api.am.wso2.com

and hosts config in (172.24.64.114) server:

  172.24.64.114    api.am.wso2.com

After invoke nginx url (172.24.64.116) it redirects to 172.24.64.114 that is site is not reachable!

解决方案

When you configure the API Manager with Proxy Port configurations, it is required to specify a Hostname as well. The same Hostname needs to be configured in the Nginx under server configurations. Further, under upstream, you have to configure the IP address of the API Manager nodes to direct the requests.

Since you are having a dedicated Nginx server (.116) in the middle, configure the Nginx server's IP address (.116) and the Hostname of the API Manager (api.am.wso2.com) in the Client node's (.239) Hosts entry. This will make sure that when you type the Hostname: api.am.wso2.com in the Client's node, the request will be dispatched to the Nginx server and then the Nginx will make the communication with the Upstream servers that have been configured.

Try out configuring the Hosts entries correctly in the Client's node and verify the behavior. A sample entry in the Client's Hosts will be as following

172.24.64.116 api.am.wso2.com

这篇关于wso2 api manager 3.2.0 nginx 负载均衡无法访问此站点错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆