Nginx和apache 配置

當nginx須要作反向代理和負載均衡的時候配置以下:html

upstream mir_k8s_service_server {  
      server  10.111.11.83:8080 weight=10;
    server  10.111.11.84:8080 weight=10;

  #也能夠不須要weight, 用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 500 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;
}

  

  當Apache須要作反向代理的時候配置以下:nginx

而且須要配置相應的mod_available, 如:web

拷貝文件到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.confapache

爲須要加載的mod創建連接:api

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 ide

ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.loadui

ServerName localhost
Listen 3000

<VirtualHost *:3000>
        ServerAdmin webmaster@localhost
        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://172.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>
相關文章
相關標籤/搜索