nginx负载均衡解决图⽚⽆法加载问题ngnix配置完upstream,f如下
upstream rvice_lb{
rver localhost:8080;
rver localhost:8081;
}
rver 模块,添加下⽅红⾊标注的内容后,图⽚能够加载出来了
rver {
listen 80;
rver_name localhost;
location / {
proxy_pass rvice_lb;
proxy_t_header Host $host;
proxy_t_header X-Real-IP $remote_addr;大学英语作文网
proxy_t_header REMOTE-HOST $remote_addr;
proxy_t_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
附录:
#ur nobody;
worker_process 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
incredibles#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include pes;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_ur [$time_local] "$request" '
# '$status $body_bytes_nt "$http_referer" '
# '"$http_ur_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
ndfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream rver_lb{
rver localhost:8080;
rver localhost:8081;
}
rver {
listen 80;
rver_name rver_lb;
#chart koi8-r;
#access_log logs/host.access.log main;
infre#注释原有的配置
#location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
#}
location / {
proxy_pass rver_lb;relong
proxy_t_header Host $host;
proxy_t_header X-Real-IP $remote_addr;
proxy_t_header REMOTE-HOST $remote_addr;
proxy_t_header X-Forwarded-For $proxy_add_x_forwarded_for;
crooked歌词}
#error_page 404 /404.html;
# redirect rver error pages to the static page /50x.html
#
error_page 500502503504 /50x.html;
location = /50x.html {
root html;
launch
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass 127.0.0.1;
#}
# pass the PHP scripts to FastCGI rver 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;
#}
新东方 koolearn# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
英语免费学习网站#
#location ~ /\.ht {
# deny all;
#}
}
subscriber# another virtual host using mix of IP-, name-, and port-bad configuration #
#rver {
布兰妮 墨菲
# listen 8000;
# listen somename:8080;
# rver_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS rver
#
#rver {
# listen 443 ssl;
# rver_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_ssion_cache shared:SSL:1m;
# ssl_ssion_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_rver_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}