nginx_chef_api_lb.conf.erb 2.06 KB
server {
  listen <%= @server_port %>;
  server_name <%= @server_name %>;
  access_log /var/log/chef-server/nginx/access.log opscode;

  <% if @server_proto == "https" -%>
  ssl on;
  ssl_certificate <%= @ssl_certificate %>;
  ssl_certificate_key <%= @ssl_certificate_key %>;

  ssl_session_timeout 5m;

  ssl_protocols <%= @ssl_protocols %>;
  ssl_ciphers <%= @ssl_ciphers %>;
  ssl_prefer_server_ciphers on;

  <% end -%>
  root <%= File.join(@dir, "html") %>;

  client_max_body_size <%= @client_max_body_size %>;

  proxy_set_header Host $host:$server_port;
  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 <%= @server_proto %>;
  proxy_pass_request_headers on;
  proxy_connect_timeout   1;
  proxy_send_timeout      300;
  proxy_read_timeout      300;

  error_page 404 =404 /404.html;
  error_page 503 =503 /503.json;

  location /nginx_status {
    stub_status on;
    access_log   off;
    allow 127.0.0.1;
    deny all;
  }

  location /version {
    types { }
    default_type text/plain;
    alias /opt/chef-server/version-manifest.txt;
  }

  location /docs {
    index index.html ;
    alias /opt/chef-server/docs;
  }

  # bookshelf
  location ~ "/<%= node['chef_server']['erchef']['s3_bucket'] %>/{0,1}.*$" {
    proxy_pass http://bookshelf;
  }

  location ~ "^/(?:stylesheets|javascripts|images|facebox|css|favicon|robots|humans)/{0,1}.*$" {
    if ($http_x_chef_version ~* "^(\d+\.\d+?)\..+$") {
      error_page 400 =400 /400-chef_client_manage.json;
      return 400;
    }
    proxy_pass http://chef_server_webui;
    proxy_pass_request_headers off;
    proxy_cache webui-cache;
    proxy_cache_valid 200 302 300m;
    proxy_cache_valid 404 1m;
  }

 location = /_status {
    proxy_pass http://erchef/_status;
  }

 location = /_status/ {
    proxy_pass http://erchef/_status;
  }

  location / {
    set $my_upstream erchef;
    if ($http_x_ops_userid = "") {
      set $my_upstream chef_server_webui;
    }
    proxy_redirect http://$my_upstream /;
    proxy_pass http://$my_upstream;
  }
}