车皮 发表于 2018-11-11 09:51:15

nginx 配置域名转发和进行ip限制

user nginx;  
worker_processes auto;
  
error_log /var/log/nginx/error.logerror;
  
pid /var/run/nginx.pid;
  

  
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
  
include /usr/share/nginx/modules/*.conf;
  

  
events {
  
    worker_connections1024;
  
}
  

  

  
http {
  
    log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
  
                      '$status $body_bytes_sent "$http_referer" '
  
                      '"$http_user_agent" "$http_x_forwarded_for"';
  

  
    access_log/var/log/nginx/access.logmain;
  

  
    sendfile            on;
  
    tcp_nopush          on;
  
    tcp_nodelay         on;
  
    keepalive_timeout   65;
  
    types_hash_max_size 2048;
  

  
    include             /etc/nginx/mime.types;
  
    default_type      application/octet-stream;
  

  
    # Load modular configuration files from the /etc/nginx/conf.d directory.
  
    # See http://nginx.org/en/docs/ngx_core_module.html#include
  
    # for more information.
  
    #include /etc/nginx/conf.d/*.conf;
  
    server {
  listen 80;
  server_name www.fuweichao.com;
  location / {
  proxy_pass
  proxy_redirect default;
  proxy_set_header Host $host;    #这一行如果不设置会把域名转成ip。
  deny all;
  }
  
   server {
  listen 80;
  server_name www.xxn.com;
  location / {
  proxy_pass http://www.xxn.com:9080/;
  proxy_redirect default;
  proxy_set_header Host $host;
  deny all;
  }
  
    }


页: [1]
查看完整版本: nginx 配置域名转发和进行ip限制