#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;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#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;
# }
#}
}
求解
1.将127.0.0.1 映射到local.server.com
2.配置文件主要如下:
http {
# 实现负载均衡
upstream dis{
server 192.168.0.108:8080 weight=1; # 另一台局域网内服务器
server 127.0.0.1:8080 weight=1; # 本台服务器
}
server{
listen 9090;
server_name local.server.com;
location / {
proxy_pass http://dis;
}
}
}
3. 访问local.server.com:9090 即可映射到配置的两台服务器。 权重为1:1
有点没看懂 我应该改哪里呢 大神
@skateweb:
如果是windows,打开系统目录:c:/windows/system32/drivers/etc找到hosts文件,打开hosts文件并在最后面新添加一条记录 例如:127.0.0.1 local.server.com
如果是mac,http://www.cnblogs.com/malcolmfeng/p/6816119.html。
@Mal
按着你说的加上了 不过 就第一次访问 0.4秒 之后刷新 就又会慢了 又要等好久 我试过好几次,没回在性的网页输入网址就很快 只要一刷新就很慢求解
colmF:
@MalcolmF: 在地址栏点击回车刷新 第一次 很慢,我连着点击两次 就又很快了 咋回事啊
@skateweb: 分配到这两台服务器的 比重是 1:1 。 可能是分配到某一台的时候有问题。 你要确定两台都可以正常访问。
@MalcolmF: 我现在在公司自己电脑做测试,那个有问题擦。杂看啊 。可不可以就先用我的电脑来做访问啊,先不用两个服务器呢。求解,有方法吗?
@skateweb: 可以再装个linux
@MalcolmF: 没别的办法吗 老大
http://www.cnblogs.com/lbblog/p/5551400.html
为啥我访问 tomcat 速度非常慢啊 超级慢 求解 大神