Nginx和apache 配置

当nginx需要做反向代理和负载均衡的时候配置如下:

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需要做反向代理的时候配置如下:

并且需要配置相应的mod_available, 如:

拷贝文件到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

为需要加载的mod建立链接:

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 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>

  

  

posted @ 2016-02-02 10:37  飞鸟投林  阅读(303)  评论(0编辑  收藏  举报