nginxã§ã¡ã³ããã³ã¹ãã¼ã¸ç¨æããæ
LT;DR
ãã£ã±å 輩ï¼
ãã£ã±å 輩ã®ããã°ãèªãã§
åããããªãã¨ãæè¿ãã£ã¦ããã®ã§ã¡ã¢ã
追è¨(03/12) 14:00
- ãªãã¤ã¬ã¯ãããã¾ãããã¨ã®ãã¨
- 503ã§ãè¿äºãã¾ãããã¨ã®ãã¨
ã¡ã³ããã³ã¹æã«ã¡ã³ããã¼ã¸ã«ãªãã¤ã¬ã¯ãããã®ããã¾ããã
— ãã㯠(@sora_h) March 12, 2015
@kenjiskywalker @sora_h å
ãã¿ã®èªåã®è¨äºã¯503è¿ãã¦ãã http://t.co/lONIVrv7OF
— fujiwara (@fujiwara) March 12, 2015
@kenjiskywalker @sora_h éçãã¼ã¸æ´æ°ãã¦å·®ãæ¿ããããã§ããããããªãã§ãããã
— fujiwara (@fujiwara) March 12, 2015
@kenjiskywalker @fujiwara ãããããã話ããã¡ãã£ã¨åéããã¦ããéçãã¼ã¸æ´æ°ã®å·®ãæ¿ããããªãã®ã§ã¯ã
— ãã㯠(@sora_h) March 12, 2015
ãã¼SEO(disallow: /)ã ã£ãã®ã§å®å ¨ã«ç¡è¦ãã¦ã
nginxã«è¨å®ãã¦ããã¡ã³ããã³ã¹ã¢ã¼ãã®æ¡ä»¶
/var/nginx/html/maintenance/maintenance.html
ãã¡ã¤ã«ãããã°ã¡ã³ããã³ã¹ã¢ã¼ãã¨ãã¦maintenance.html
ã表示ããããã«/healthcheck
ã®ãªã¯ã¨ã¹ãã¯ã¡ã³ããã³ã¹ã¢ã¼ãã§ãéã管çIPã¢ãã¬ã¹ããã¯ã¡ã³ããã³ã¹ã¢ã¼ãã§ãéã
ã¨ãã3ç¹ãè¨å®ãã¦ãã¾ãã
- nginx.conf
upstream example_pool { server 127.0.0.1:3000; } geo $allow_ip_flag { default 0; 192.0.2.0/24 1; #TEST-NET-1 198.51.100.0/24 1; #TEST-NET-2 } server { listen 80; server_name example.com; access_log /var/log/nginx/example_com_access.log ltsv; error_log /var/log/nginx/example_com_error.log warn; root /var/nginx/html/example; location /robots.txt { alias /var/nginx/html/robots.txt; } location / { ### ã¡ã³ããã³ã¹ã®è¨å® ãããã ############################### if ( -e /var/nginx/html/maintenance/maintenance.html ) { set $maintenance true; } # health checkã®ãªã¯ã¨ã¹ãã¯ãã°ã«åºããã« # ã¡ã³ããã³ã¹ãã¼ã¸ãééãã if ( $request_uri ~ /healthcheck ) { set $maintenance false; access_log off; } # 許å¯IPã¢ãã¬ã¹ãªãã¡ã³ããã³ã¹ãã¼ã¸ãééãã if ( $allow_ip_flag ) { set $maintenance false; } # ãã以å¤ã¯/maintenance.htmlã«é£ã°ã if ( $maintenance = true ) { rewrite ^ /maintenance.html redirect; } location /maintenance.html { alias /var/nginx/html/maintenance/maintenance.html; expires 0; } ### ã¡ã³ããã³ã¹ã®è¨å® ããã¾ã§ ############################### proxy_pass http://example_pool; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 710M; proxy_connect_timeout 3000; proxy_send_timeout 3000; proxy_read_timeout 3000; break; } }
nginxã¯è¤æ°ã®æ¡ä»¶ã®å ´åbitç«ã¦ã¦å¤æããã®ç¥ããªãã£ãã
ããããã®ã¯ã¨ã¬ã¬ã³ãã«ngx_mrubyã§ãã£ãæ¹ãéç¨æ¥½ããã