Я пытаюсь получить изображения, не найденные на нашем промежуточном сервере, для автоматической загрузки с рабочего сервера. Я протестировал это локально со следующей конфигурацией на nginx 1.6.2: И это сработало, как ожидалось
server {
root /var/www/html/test;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name nginx1.local;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ @fallback;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location @fallback{
proxy_pass http://nginx2.local;
}
}
Однако на нашем производственном сервере я не могу заставить его работать. Производство работает под управлением nginx 1.1.19, и мне интересно, изменилось ли что-то с proxy_pass с тех пор. Пусть будет известно, что я новичок на этой работе и пока не могу нести ответственность за то, что все устарело.
server {
# Specify default_server here as catch-all (sites not in any other 'server' blocks)
listen 80; # ipv4
#listen [::]:80 default ipv6only=on; # ipv6
root /var/www/testing/public;
index index.html index.htm /index.html; # Ending /index.html is a sort of 'internal redirect' because of the starting slash
# Set to "" (empty) as catch-all (in conjuction with listen directive)
server_name "testing.media.foo.com";
##
# Logging Settings
##
access_log /var/www/testing/logs/access.log;
error_log /var/www/testing/logs/error.log;
# Specify a charset
charset utf-8;
# Implement filename-based cache busting ala h5bp
#include /etc/nginx/h5bpconf/cache-busting.conf;
rewrite ^/(.+)\.v(\d+)\.(js|css|png|jpg|jpeg|gif)$ /$1.$3;
# Include other h5bp conf files
include /etc/nginx/h5bpconf/x-ua-compatible.conf;
include /etc/nginx/h5bpconf/protect-system-files.conf;
#include /etc/nginx/h5bpconf/cross-domain-ajax.conf;
include /etc/nginx/h5bpconf/no-transform.conf;
location / {
## Handle alternate domains first
# include /var/www/testing/nginx_conf/alternate_domains.conf;
# First attempt to serve request as file, then
# as directory, then fall back
try_files $uri $uri/ @fallback;
# these h5bp configs only have an effect if try_files finds a file
include /etc/nginx/h5bpconf/expires.conf;
include /etc/nginx/h5bpconf/cross-domain-fonts.conf;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location @fallback {
proxy_pass http://media.foo.com;
#return 404;
}
# if you don't like seeing all the errors for missing favicon.ico in root
location = /favicon.ico { access_log off; log_not_found off; }
# if you don't like seeing errors for a missing robots.txt in root
location = /robots.txt { access_log off; log_not_found off; }
# this will prevent files like .htaccess .htpassword .secret etc from being served
# You can remove the log directives if you wish to
# log any attempts at a client trying to access a hidden file
#location ~ /\. { deny all; access_log off; log_not_found off; }
#location /doc/ {
# alias /usr/share/doc/;
# autoindex on;
# allow 127.0.0.1;
# deny all;
#}
# Only for nginx-naxsi : process denied requests
#location /RequestDenied {
# For example, return an error code
#return 418;
#}
#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 /usr/share/nginx/www;
#}
}
тестовый сервер - testing.media.foo.com, а производственный сервер - media.foo.com, если изображение не найдено на сайте testing.media.foo.com, я хочу, чтобы оно загружалось с media.foo.com вместо того, чтобы всегда копировать изображения в тестирование из производства.
edit: Вот вывод nginx -V --prefix = / etc / nginx --conf-path = / etc / nginx / nginx.conf --error-log-path = / var / log / nginx / error.log - -http-client-body-temp-path = / var / lib / nginx / body --http-fastcgi-temp-path = / var / lib / nginx / fastcgi --http-log-path = / var / log / nginx / access.log --http-proxy-temp-path = / var / lib / nginx / proxy --http-scgi-temp-path = / var / lib / nginx / scgi --http-uwsgi-temp-path = / var / lib / nginx / uwsgi --lock-path = / var / lock / nginx.lock --pid-path = / var / run / nginx.pid --with-debug --with-http_addition_module --with -http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_module_random_index -http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1 = / usr / include / openssl --with-md5 = / usr / include / openssl --with- mail --with-mail_ssl_module --add-module = / b uild / buildd / nginx-1.1.19 / debian / modules / nginx-auth-pam --add-module = / build / buildd / nginx-1.1.19 / debian / modules / chunkin-nginx-module --add-module = / build / buildd / nginx-1.1.19 / debian / modules / headers-more-nginx-module --add-module = / build / buildd / nginx-1.1.19 / debian / modules / nginx-development-kit - -add-module = / build / buildd / nginx-1.1.19 / debian / modules / nginx-echo --add-module = / build / buildd / nginx-1.1.19 / debian / modules / nginx-http-push - -add-module = / build / buildd / nginx-1.1.19 / debian / modules / nginx-lua --add-module = / build / buildd / nginx-1.1.19 / debian / modules / nginx-upload-module - -add-module = / build / buildd / nginx-1.1.19 / debian / modules / nginx-upload-progress --add-module = / build / buildd / nginx-1.1.19 / debian / modules / nginx-upstream- справедливо --add-module = / build / buildd / nginx-1.1.19 / debian / modules / nginx-dav-ext-module