2

我在两台 IIS 服务器前设置了 Nginx。主要目标是负载平衡、ssl 卸载和缓存静态内容。

当所有上游服务器不可用或抛出 404 错误时,我遇到的困难是显示维护页面。我在我的 NginX 机器上创建了一个 maintenance.html 文件,但无法加载它。我有时可以让它加载 IIS 404,有时让它加载默认的 NginX 404。我真正想做的是,如果由于某种原因所有上游都关闭或抛出 404 是向用户显示“维护”页面并最终在该页面中放入一些代码以提醒我所有上游服务器都已关闭。

这是我的配置:

# -------------------------------------------
#       ACTUAL SITE WITH - SSL CERTIFICATE
#------------------------------------------


# Backend IIS Servers
upstream backend-iis {

    # Health Checks
    #healthcheck_enabled; 
    #healthcheck_delay 5000; 
    #healthcheck_timeout 5000; 
    #healthcheck_failcount 1; 

    # Upstream Servers
        server ww1.pickle.com  max_fails=3  fail_timeout=31s;
        server ww2.pickle.com  max_fails=3  fail_timeout=31s;
        #server ww3.pickle.com;

      # Sticky Sessions
      #sticky;
      #ip_hash;

}


# Server Configuration
server {

    # Server Specific Settings
       server_name        www.pickle.com;
       access_log         /var/log/nginx/www.pickle.com.log ;
       keepalive_timeout  5;
       allow              all;
       server_tokens      off; 
       gzip               on;
       gzip_vary          on;

    # SSL Settings (with SPDY 2)
       ssl on;
       listen 443 ssl spdy; 
       ssl_certificate /usr/share/nginx/ssl-certs/pickle_com/pickle_basic.crt;
    #  ssl_certificate /usr/share/nginx/ssl-certs/pickle_com/pickle_ev.crt;
       ssl_certificate_key        /usr/share/nginx/ssl-certs/pickle_com/pickle.com.key;
       ssl_session_timeout        15m;
       ssl_protocols              SSLv3 TLSv1 TLSv1.1 TLSv1.2;
       ssl_ciphers                RC4:HIGH:!aNULL:!MD5;
       ssl_prefer_server_ciphers  on;
       ssl_session_cache          shared:SSL:10m;




    # Proxy Pass to: backend-iis
    location / {

             #root               /usr/share/nginx/sites/pickle-down/;

         # Proxy Header to Keep Ip Address and Hostname
         proxy_redirect    off;
         proxy_set_header  Host              "www.pickle.com";
         proxy_set_header  X-Real-IP         $remote_addr;
         proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
         proxy_set_header  X-Forwarded-Proto $scheme;

         # Proxy Pass to Backend IIS Servers
         proxy_pass             http://backend-iis;
         # proxy_next_upstream    error timeout http_404;
         proxy_temp_path        /usr/share/nginx/temp;

         #Intercept Proxy Errors (show Nginx Error Pages)
         #proxy_intercept_errors on; 
                 error_page 404 500 502 503 504 = @maintenance;

    }


    # Proxy Pass to: backend-iis
    location @maintenance {
         internal;
         root        /usr/share/nginx/sites/pickle-down;
         index  maintenance.html index.html index.htm;
         allow all;

    }



   error_page 500 502 503 504 /50x.html;
   location = /50x.html {
   root html;
  }

   error_page 404 /404.html;
   location = /usr/share/nginx/sites/pickle-down/404.html {
   root html;
  }
}
4

1 回答 1

0

你用的是免费版吗?

我认为您正在寻找的是名为NGINX Plus的非免费版本 。

于 2014-02-21T15:40:55.453 回答