When Nginx needs to do reverse proxy and load balancing, configure the following:
Upstream Mir_k8s_service_server { server 10.111.11.83:8080 weight=10; Server 10.111.11.84:8080 weight=10; #也可以不需要weight, with Ip_hash; #ip_hash; #server 10.111.11.83:8080; #server 10.111.11.84:8080;} server { listen 3051; Location/{ root E:\Projects\mir-k8s-ui\dist; } Location/mir-k8s-service {proxy_pass http://mir_k8s_service_server; Proxy_set_header Connection '; Proxy_http_version 1.1; Chunked_transfer_encoding off; Proxy_buffering off; Proxy_cache off; } Error_page 502 503 504/50x.html; Location =/50x.html { root/usr/share/nginx/html; } Proxy_redirect off; Proxy_set_header Host $host; Proxy_set_header x-real-ip $remote _addr; Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;}
When Apache needs to do a reverse proxy, it is configured as follows:
And you need to configure the appropriate mod_available, such as:
Copy files to sites-available:/etc/apache2/sites-available/webb-ui-proxy.conf
Ln-s/etc/apache2/sites-available/webb-ui-proxy.conf/etc/apache2/sites-enabled/webb-ui-proxy.conf
To create a link to a mod that needs to be loaded:
Ln-s/etc/apache2/mods-available/proxy.load/etc/apache2/mods-enabled/proxy.load
Ln-s/etc/apache2/mods-available/proxy_http.load/etc/apache2/mods-enabled/proxy_http.load
Ln-s/etc/apache2/mods-available/rewrite.load/etc/apache2/mods-enabled/rewrite.load
servername localhostlisten 3000<virtualhost *:3000> ServerAdmin [email protected] Documentroot/bdaas-webb-ui rewriteengine on <Directory/bdaas-webb-ui/> Options Indexes followsymlinks allowoverride None Require all granted </Directory> Rewriterule ^/(guardian/.*) http://172.16.50.80:7007/$1 [p,l] rewriterule ^/(chinacloud/.*) http://172.16.50. 11/$1 [p,l] rewriterule ^/(store/.*) http://172.16.50.83:9763/$1 [p,l] rewriterule ^/(publisher/.*) HTTP://1 72.16.50.83:9763/$1 [p,l] rewriterule ^/(registry/.*) http://172.16.50.83:9763/$1 [p,l] ProxyPreserveHost on Proxyrequests off Proxypass/hubble-wso2-report-api http:10.111.10.12:8080 proxypassreverse/hubble- Wso2-report-api http:10.111.10.12:8080
Errorlog ${apache_log_dir}/error.log customlog ${apache_log_dir}/access.log combined </VirtualHost>
Nginx and Apache Configuration