全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 8844|回复: 11

[nginx] Nginx反向代理,后无法显示图片

[复制链接]
发表于 2010-10-29 00:25:10 | 显示全部楼层 |阅读模式
  1.         location /image/ {
  2.             proxy_pass http://www.xxx.cc/image/;
  3.             proxy_redirect off;
  4. proxy_set_header X-Real-IP $remote_addr;
  5. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  6.         }
复制代码
采用了如上代码。无法显示图片,目标站是APACHE的,并没有开启防盗链。
奇怪的是除了图片,其他格式的文件均正常。
nginx.conf
  1. user  www www;

  2. worker_processes 1;

  3. error_log  /home/wwwlogs/nginx_error.log  crit;

  4. pid        /usr/local/nginx/logs/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;

  7. events
  8.         {
  9.                 use epoll;
  10.                 worker_connections 51200;
  11.         }

  12. http
  13.         {
  14.                 include       mime.types;
  15.                 default_type  application/octet-stream;

  16.                 server_names_hash_bucket_size 128;
  17.                 client_header_buffer_size 32k;
  18.                 large_client_header_buffers 4 32k;
  19.                 client_max_body_size 8m;

  20.                 sendfile on;
  21.                 tcp_nopush     on;

  22.                 keepalive_timeout 60;

  23.                 tcp_nodelay on;

  24.                 fastcgi_connect_timeout 300;
  25.                 fastcgi_send_timeout 300;
  26.                 fastcgi_read_timeout 300;
  27.                 fastcgi_buffer_size 64k;
  28.                 fastcgi_buffers 4 64k;
  29.                 fastcgi_busy_buffers_size 128k;
  30.                 fastcgi_temp_file_write_size 256k;

  31.                 gzip on;
  32.                 gzip_min_length  1k;
  33.                 gzip_buffers     4 16k;
  34.                 gzip_http_version 1.0;
  35.                 gzip_comp_level 2;
  36.                 gzip_types       text/plain application/x-javascript text/css application/xml;
  37.                 gzip_vary on;

  38.                 #limit_zone  crawler  $binary_remote_addr  10m;

  39. server
  40.         {
  41.                 listen       80;
  42.                 server_name www.xxx.com;
  43.                 index index.html index.htm index.php;
  44.                 root  /home/wwwroot;

  45.                 location ~ .*\.(php|php5)?$
  46.                         {
  47.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  48.                                 fastcgi_index index.php;
  49.                                 include fcgi.conf;
  50.                         }

  51.                 location /status {
  52.                         stub_status on;
  53.                         access_log   off;
  54.                 }

  55.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  56.                         {
  57.                                 expires      30d;
  58.                         }

  59.                 location ~ .*\.(js|css)?$
  60.                         {
  61.                                 expires      12h;
  62.                         }

  63.                 log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  64.              '$status $body_bytes_sent "$http_referer" '
  65.              '"$http_user_agent" $http_x_forwarded_for';
  66.                 access_log  /home/wwwlogs/access.log  access;
  67.         }
  68. include vhost/*.conf;
  69. }
复制代码

[ 本帖最后由 solar 于 2010-10-29 13:35 编辑 ]
 楼主| 发表于 2010-10-29 00:32:31 | 显示全部楼层
没人用过吗?
发表于 2010-10-29 00:35:39 | 显示全部楼层
上次测试过

对象是hostloc 登录的时候验证码显示不鸟

后来没管  
不咋用反向
发表于 2010-10-29 01:00:50 | 显示全部楼层
试一试加上这个呢?
proxy_set_header Host $proxy_host;

评分

参与人数 1威望 +10 收起 理由
solar + 10 原创内容

查看全部评分

 楼主| 发表于 2010-10-29 01:23:58 | 显示全部楼层
原帖由 loveloli 于 2010-10-29 01:00 发表
试一试加上这个呢?
proxy_set_header Host $proxy_host;

加了,不管用
发表于 2010-10-29 01:42:34 | 显示全部楼层
proxy_pass http://www.xxx.cc 改为这样。

评分

参与人数 1威望 +10 收起 理由
solar + 10 原创内容

查看全部评分

 楼主| 发表于 2010-10-29 03:57:13 | 显示全部楼层

回复 6# 的帖子

不行。问题不在路径上。 用得 是军哥的LNMP0.5
 楼主| 发表于 2010-10-29 12:50:55 | 显示全部楼层
继续求助
发表于 2010-10-29 12:59:42 | 显示全部楼层
location ~ ^/(image)/ {
            proxy_pass http://www.xxx.cc;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
绝对是这样了。

评分

参与人数 1威望 +10 收起 理由
solar + 10 路径是OK的,问题应该不在路径上。 ...

查看全部评分

 楼主| 发表于 2010-10-29 13:36:59 | 显示全部楼层

回复 9# 的帖子

看以下我的nginx.conf有没有问题?
  1. user  www www;

  2. worker_processes 1;

  3. error_log  /home/wwwlogs/nginx_error.log  crit;

  4. pid        /usr/local/nginx/logs/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;

  7. events
  8.         {
  9.                 use epoll;
  10.                 worker_connections 51200;
  11.         }

  12. http
  13.         {
  14.                 include       mime.types;
  15.                 default_type  application/octet-stream;

  16.                 server_names_hash_bucket_size 128;
  17.                 client_header_buffer_size 32k;
  18.                 large_client_header_buffers 4 32k;
  19.                 client_max_body_size 8m;

  20.                 sendfile on;
  21.                 tcp_nopush     on;

  22.                 keepalive_timeout 60;

  23.                 tcp_nodelay on;

  24.                 fastcgi_connect_timeout 300;
  25.                 fastcgi_send_timeout 300;
  26.                 fastcgi_read_timeout 300;
  27.                 fastcgi_buffer_size 64k;
  28.                 fastcgi_buffers 4 64k;
  29.                 fastcgi_busy_buffers_size 128k;
  30.                 fastcgi_temp_file_write_size 256k;

  31.                 gzip on;
  32.                 gzip_min_length  1k;
  33.                 gzip_buffers     4 16k;
  34.                 gzip_http_version 1.0;
  35.                 gzip_comp_level 2;
  36.                 gzip_types       text/plain application/x-javascript text/css application/xml;
  37.                 gzip_vary on;

  38.                 #limit_zone  crawler  $binary_remote_addr  10m;

  39. server
  40.         {
  41.                 listen       80;
  42.                 server_name www.xxx.com;
  43.                 index index.html index.htm index.php;
  44.                 root  /home/wwwroot;

  45.                 location ~ .*\.(php|php5)?$
  46.                         {
  47.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  48.                                 fastcgi_index index.php;
  49.                                 include fcgi.conf;
  50.                         }

  51.                 location /status {
  52.                         stub_status on;
  53.                         access_log   off;
  54.                 }

  55.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  56.                         {
  57.                                 expires      30d;
  58.                         }

  59.                 location ~ .*\.(js|css)?$
  60.                         {
  61.                                 expires      12h;
  62.                         }

  63.                 log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  64.              '$status $body_bytes_sent "$http_referer" '
  65.              '"$http_user_agent" $http_x_forwarded_for';
  66.                 access_log  /home/wwwlogs/access.log  access;
  67.         }
  68. include vhost/*.conf;
  69. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-16 12:53 , Processed in 0.066166 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表