KONG 的使用

kong docker 安装

  • https://docs.konghq.com/gateway/latest/install/docker/

创建一个网络

 docker network create kong-net

Start a PostgreSQL container:


docker run -d --name kong-database --network=kong-net -p 5432:5432 -e "POSTGRES_USER=kong" -e "POSTGRES_DB=kong" -e "POSTGRES_PASSWORD=kongpass" postgres:13

docker run --rm --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_PG_PASSWORD=kongpass" -e "KONG_PASSWORD=test"  kong/kong-gateway:3.5.0.1 kong migrations bootstrap
docker run -d --name kong-gateway --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_PG_USER=kong" -e "KONG_PG_PASSWORD=kongpass" -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" -e "KONG_PROXY_ERROR_LOG=/dev/stderr" -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" -e "KONG_ADMIN_LISTEN=0.0.0.0:8001" -e "KONG_ADMIN_GUI_URL=http://localhost:8002" -e KONG_LICENSE_DATA -p 8000:8000 -p 8443:8443 -p 8001:8001 -p 8444:8444 -p 8002:8002 -p 8445:8445 -p 8003:8003 -p 8004:8004  kong/kong-gateway:3.5.0.1



docker run -d --network=kong-net -p 8201:8201 --name pda_runing pda

服务:wms-main-pc-java-ui
端口:8100
nginx:
wms-main-pc-java-ui.conf
server {
        listen       8100;
        server_name  localhost;
        access_log logs/test-wms-main-pc-java-ui.eminxing.log; #修改日志目录
        root /data/apps/wms-main-pc-java-ui;
        index  index.html index.htm;
        location / {
                try_files $uri $uri/ @router;
                add_header Cache-Control no-cache;
                add_header Access-Control-Allow-Origin *;
                add_header Access-Control-Allow-Headers *;
                add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
        }
        location @router {
             rewrite ^.*$ /index.html last;
        }
        location /api/ {
            proxy_set_header Host $proxy_host;
            proxy_pass http://test-wms-gateway.eminxing.com/【需要修改】;
        }
         location /web/returnorder/ {
            proxy_pass http://localhost:8102/;
        }
        location /web/receipt/ {
            proxy_pass http://localhost:8105/;
        }
        location /web/base/ {
            proxy_pass http://localhost:8107/;
        }
        location /pda/ {
            proxy_pass http://localhost:8200/;
        }
}



服务:wms-returnorder-pc-java-ui
端口:8102
nginx:
wms-returnorder-pc-java-ui.conf
server {
        listen       8102;
        server_name  localhost;
        access_log logs/test-wms-returnorder-pc-java-ui.eminxing.log; #修改日志目录
        root /data/apps/wms-returnorder-pc-java-ui;
        index  index.html index.htm;
        location ~ / {
                try_files $uri $uri/ @router;
                add_header Cache-Control no-cache;
                add_header Access-Control-Allow-Origin *;
                add_header Access-Control-Allow-Headers *;
                add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
        }
        location @router {
             rewrite ^.*$ /index.html last;
        }
}




服务:wms-receipt-pc-java-ui
端口:8105
nginx:
wms-receipt-pc-java-ui.conf
server {
        listen       8105;
        server_name  localhost;
        access_log logs/test-wms-receipt-pc-java-ui.eminxing.log; #修改日志目录
        root /data/apps/wms-receipt-pc-java-ui;
        index  index.html index.htm;
        location ~ / {
                try_files $uri $uri/ @router;
                add_header Cache-Control no-cache;
                add_header Access-Control-Allow-Origin *;
                add_header Access-Control-Allow-Headers *;
                add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
        }
        location @router {
             rewrite ^.*$ /index.html last;
        }
}



服务:wms-base-pc-java-ui
端口:8107
nginx:
wms-base-pc-java-ui.conf
server {
        listen       8107;
        server_name  localhost;
        access_log logs/test-wms-base-pc-java-ui.eminxing.log; #修改日志目录
        root /data/apps/wms-base-pc-java-ui;
        index  index.html index.htm;
        location ~ / {
                try_files $uri $uri/ @router;
                add_header Cache-Control no-cache;
                add_header Access-Control-Allow-Origin *;
                add_header Access-Control-Allow-Headers *;
                add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
        }
        location @router {
             rewrite ^.*$ /index.html last;
        }
}


wms-main-pda-java-ui 8200

服务:wms-main-pda-java-ui
端口:8200
nginx:
wms-main-pda-java-ui.conf
server {
        listen       8200;
        server_name  localhost;
        access_log logs/test-wms-wms-main-pda-java-ui.eminxing.log; #修改日志目录
        root /data/apps/wms-main-pda-java-ui;
        index  index.html index.htm;
        location ~ / {
                try_files $uri $uri/ @router;
                add_header Cache-Control no-cache;
                add_header Access-Control-Allow-Origin *;
                add_header Access-Control-Allow-Headers *;
                add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
        }
        location @router {
             rewrite ^.*$ /index.html last;
        }
}


  • nginx 别名设置
        location ~ ^/pda(?:/(.\*))?$ {
                alias /data/apps/rb-fe-main-pda/;
                try_files $1 $1/ index.html =404;
        }
        location ~ ^/wms/(?:[^/]+/)?pda(?:/(.*))?$ {
                alias /data/apps/rbwms-ui/pda/;
                try_files $1 $1/ index.html =404;
                error_page 404 =200 /data/apps/rbwms-ui/pda/index.html;
        }


        location ~ ^/tws/(?:[^/]+/)?pda(?:/(.*))?$ {
                alias /data/apps/tws/pda/;
                try_files $1 $1/ index.html =404;
                error_page 404 =200 /data/apps/tws/pda/index.html;
        }
Last Updated:
Contributors: 刘荣杰