5
嗨我想配置我的nginx服務器代理亞馬遜S3,並做類似mod_rewrite在Apache - 如果代理亞馬遜是404(文件不存在亞馬遜),然後將我重定向到我的本地文件。這可能嗎?nginx代理和404重定向
這是我nginx的配置文件:
upstream app{
server 127.0.0.1:3000;
}
server {
listen 0.0.0.0:80;
server_name www.mypage.com mypage.com;
access_log /var/log/nginx/mypagecom.log;
location /photos{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://amazons3.mypage.com/photos;
proxy_redirect off;
error_page 404 /myerrorfile.jpg;
}
location/{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://app;
proxy_redirect off;
}
}
誰能幫助我?
THX !! :)它是完美的作品:) –