php yii iconv,Yii 中文网

博主在Ubuntu系统上配置了Nginx负载均衡,设置两个项目basic2和basic3,使用权重1:3进行轮询。在Firefox和IE浏览器中能正常工作,但Chrome浏览器表现不稳定。问题表现为基本只显示basic3,偶尔显示basic2。已尝试清除缓存,问题未解决。寻求解决方案。
摘要由CSDN通过智能技术生成

问题

写了个简单的nginx负载均衡,发现ie,火狐,edge浏览器可以正常,可是谷歌浏览器就是不行 过程如下:我是ubuntu系统(虚拟机),ip是192.168.10.100 现在有2个项目,一个是basic2一个是basic3

nginx对应的配置文件如下:

basic2项目配置文件是test2.conf,配置了8078端口

server {

listen 8078;

listen [::]:8078;

root /var/www/html/basic2/web;

# Add index.php to the list if you are using PHP

index index.html index.htm index.nginx-debian.html index.php;

location / {

root /var/www/html/basic2/web;

# First attempt to serve request as file, then

# as directory, then fall back to displaying a 404.

#try_files $uri $uri/ =404;

if (!-e $request_filename){

rewrite ^/(.*) /index.php last;

}

}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

root /var/www/html/basic2/web;

include snippets/fastcgi-php.conf;

#

# # With php7.0-cgi alone:

# fastcgi_pass 127.0.0.1:9000;

# # With php7.0-fpm:

fastcgi_pass unix:/run/php/php7.1-fpm.sock;

}

location ~ /\.ht {

deny all;

}

}

basic3项目配置文件是test3.conf,配置了8079端口

server {

listen 8079;

listen [::]:8079;

root /var/www/html/basic3/web;

# Add index.php to the list if you are using PHP

index index.html index.htm index.nginx-debian.html index.php;

location / {

root /var/www/html/basic3/web;

# First attempt to serve request as file, then

# as directory, then fall back to displaying a 404.

#try_files $uri $uri/ =404;

if (!-e $request_filename){

rewrite ^/(.*) /index.php last;

}

}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

root /var/www/html/basic3/web;

include snippets/fastcgi-php.conf;

#

# # With php7.0-cgi alone:

# fastcgi_pass 127.0.0.1:9000;

# # With php7.0-fpm:

fastcgi_pass unix:/run/php/php7.1-fpm.sock;

}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

location ~ /\.ht {

deny all;

}

}

在浏览器分别访问,结果如下图:

至此都可以访问,现在我配置个负载均衡的服务,其配置文件是test.conf,内容如下

server {

listen 80;

listen [::]:80;

# Add index.php to the list if you are using PHP

index index.html index.htm index.nginx-debian.html index.php;

server_name www.yiibasic.cn;

location / {

proxy_pass http://webservers;

}

}

还有nginx的nginx.conf配置如下:

http {

sendfile off;

tcp_nopush on;

tcp_nodelay on;

keepalive_timeout 65;

types_hash_max_size 2048;

# server_tokens off;

# server_names_hash_bucket_size 64;

# server_name_in_redirect off;

include /etc/nginx/mime.types;

default_type application/octet-stream;

##

# SSL Settings

##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE

ssl_prefer_server_ciphers on;

##

# Logging Settings

##

access_log /var/log/nginx/access.log;

error_log /var/log/nginx/error.log;

##

# Gzip Settings

##

gzip on;

gzip_disable "msie6";

# gzip_vary on;

# gzip_proxied any;

# gzip_comp_level 6;

# gzip_buffers 16 8k;

# gzip_http_version 1.1;

# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##

# Virtual Host Configs

##

upstream webservers {

server 192.168.10.100:8078 weight=1;

server 192.168.10.100:8079 weight=3;

}

include /etc/nginx/conf.d/*.conf;

}

使用权重1:3的模式,然后在本机host文件加入192.168.10.100 www.yiibasic.cn 当我在火狐,ie下访问http://www.yiibasic.cn/ 可以看到3次basic3出现一次basic2出现的周期现象,说明成功了,可是在谷歌上始终是basic3,偶尔一下basic3一下basic2,缓存也清除了,没有作用,不知道是什么原因??

2年前

喜欢(0)

浏览(2494)

评论(4)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值