无意中看到nginx很有意思的配置

user nginx nginx;

worker_processes auto;
worker_rlimit_nofile 8192;

events {
  worker_connections 8000;
}

error_log  /dev/stderr notice;
pid        /var/run/nginx.pid;

http {

  # Hide nginx version
  server_tokens off;

  rewrite_log on;

  # mime types
  include mime.types;
  default_type application/octet-stream;

  # Update charset_types due to updated mime.types
  charset_types text/xml text/plain text/vnd.wap.wml application/x-javascript application/rss+xml text/css application/javascript application/json;

  # Format to use in log files
  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

  access_log /dev/stdout main;

  keepalive_timeout 20;
  sendfile          on;
  tcp_nopush        on;

  # Nodejs API
  upstream api {
    server 127.0.0.1:8543;
  }

  # Reverse-proxy for the Riot API, S3, and our API
  server {
    listen [::]:80;
    listen 80;

    server_name _;

    charset utf-8;

    # Resolver
    resolver         8.8.8.8 valid=300s;
    resolver_timeout 10s;

    # API, reverse proxy our API
    location /api/ {
      limit_except GET {
        deny all;
      }
      rewrite ^/api(/.*)$ $1 break;
      proxy_pass http://api;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;
    }
  } 

 

 

你可能感兴趣的:(nginx,配置,conf,resolvf)