nginx 配置转发到其他多台服务器
2017-12-14 20:45
225 查看
修改nginx.conf文件,在http下添加
然后在 location中添加
upstream site { server 127.0.0.1:9999; server 127.0.0.1:8888; server 127.0.0.1:7779; server 127.0.0.1:7777; }
然后在 location中添加
proxy_pass http://site;[/code]
这里的site 跟 upstream后面的名字对应。
全部的信息如下:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream site { server 127.0.0.1:9999; server 127.0.0.1:8888; server 127.0.0.1:7779; server 127.0.0.1:7777; }
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html;
proxy_pass http://site; }
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1; #}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
相关文章推荐
- nginx 配置域名转发到其他域名
- Nginx服务器中配置非80端口的端口转发方法详解
- AWStats 日志分析工具【配置分析其他服务器nginx日志】
- nginx安装配置启动,把前端的请求一部分转发到本地,ajax请求转发到服务器。
- nginx 后端服务器配置端口 request.getserverPort
- 了解如何将 Nginx 配置为Web服务器
- Nginx服务器安装及详细配置(动静分离)
- Windows系统下Nginx服务器的基本安装和配置方法介绍
- nginx如何配置负载多个nodejs+socketio服务器
- SSL服务器证书安装配置指南(Nginx)
- 使用RHEL5.5配置DNS服务,实现主辅DNS服务器同步以及DNS转发服务器的配置
- 【Linux】DNS服务-BIND从服务器、缓存服务器及转发服务器配置(三)
- Linux系统Nginx服务器的安装与配置方法
- Nginx + StartSSL 配置https服务器
- Nginx配置proxy_pass转发的/路径
- nginx配置图片服务器
- nginx 学习笔记(9) 配置HTTPS服务器--转载
- Nginx+Tomcat+Https 服务器负载均衡配置实践方案详解
- Centos 5.3 Nginx+php+mysql配置 独立的 Subversion (SVN)服务器
- LNMP(linux+nginx+mysql+php)服务器环境配置