Amazon kadar burada, S3 özel durum kodu izin nginx kullanarak bir çözümdür.
Bakım modu için "ON anahtarı" olarak işlev gören belirli bir dosyanın varlığını izleriz. Bulunursa, S3'e proxy_pass
isteği göndeririz - Hile return 503
içindir, ancak 503 durum kodunun işlenmesini nginx "adlandırılmış konum" a yönlendiririz.
Örnek nginx conf dosyası (sadece konuyla ilgili bitleri gösteriliyor):
server {
...
# Redirect processing of 503 status codes to a nginx "named location".
error_page 503 @maintenance;
# "Maintenance Mode" is off by default - Use a nginx variable to track state.
set $maintenance off;
# Switch on "Maintenance Mode" if a certain file exists.
if (-f /var/www/app/maintenanceON) {
set $maintenance on;
}
if ($maintenance = on) {
# For Maintenance mode Google recommend using status code: "503 Service unavailable".
return 503;
}
...
location @maintenance {
# Redirect the request to a static maintenance page hosted in Amazon S3.
# Note: Use proxy_pass instead of rewrite so we keep the 503 code (otherwise nginx serves a 302 code)
rewrite ^(.*)$ /index.html break;
proxy_pass http://bucketname.s3-website-us-east-1.amazonaws.com;
}
}
Merhaba Tom. Bunun için bir çözüm buldunuz mu? – WooDzu