The company uses K8S to build a test environment, and there are multiple sets of test exchanges. The current idea is to use an export IP for each set of test environment.
The plan:
1. Build ingress
2. Build a reverse agent
Combined with the actual situation, we use to build a reverse agent to solve this problem.
The following K8S services exist in our environment
Vipapi mall COM based on. netcore
Billapi mall COM based on PHP
www-mall-com - PHP based
Mobile mall COM based on VUE
The external domain name of vipapi-mall-com is vipapi.mall.com.
billapi-mall-com the external domain name is billapi.mall.com
kubernetes's Kube DNS address is 10.254.0.2, using coredns
We have the following namespace
branches
tags
The configuration file is as follows:
upstream vipapi { server vipapi-mall-com; #Under normal circumstances, it will be wrong to put it here, but if you add restover, it will not be wrong. Just fill in the service name of K8S here. } server { listen 80; server_name vipapi.mall.com; access_log off; resolver 10.254.0.2; #Note that the configuration of DNS resolution must be placed under the server and not under the location, otherwise it cannot be resolved. location / { proxy_http_version 1.1; proxy_set_header Connection ""; proxy_redirect off ; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 50m; client_body_buffer_size 256k; proxy_connect_timeout 30; proxy_send_timeout 30; proxy_read_timeout 60; proxy_buffer_size 256k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; proxy_temp_file_write_size 256k; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_404; proxy_max_temp_file_size 128m; proxy_pass http://vipapi; } }