Nginx和apache 配置
2016-02-02 10:37
543 查看
当nginx需要做反向代理和负载均衡的时候配置如下:
当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
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>
相关文章推荐
- Nginx详解-服务器集群
- 详解在使用CDN加速时Nginx获取用户IP的配置方法
- 基于nginx实现protobuf RPC
- Nginx安装与配置
- nginx源码修改之stub_status
- Nginx的平滑升级
- Nginx 的常用操作
- nginx源代码学习资源(不断更新)
- Nginx代理非80端口
- Ubuntu14.04.2下nginx1.6和sticky1.1模块的安装与简单配置
- Master Nginx(5) - Reverse Proxy Advanced Topics
- Nginx(3) - Controlling nginx
- Nginx(2) - Admin’s Guide
- Nginx静态网站无法显示图片问题
- Nginx(1) - Beginner’s Guide
- Master Nginx(1) - Installing Nginx and Third-Party Modules
- nginx与Apache的涉及的计算机原理说明
- Nginx+Lua服务端合并静态文件
- nginx笔记
- CentOS 6.5 安装 Nginx