qq524061227 发表于 2018-11-14 09:49:02

Nginx重定向配置

  
server{
  
      listen          80;
  
      server_name    www.sojson.com admin.sojson.com sojson.com;
  
      index index.html;
  
      access_log      syslog:server=127.0.0.1,facility=local6,tag=nginxlog_access,severity=notice main;
  
      error_log       syslog:server=127.0.0.1,facility=local6,tag=nginxlog_error;
  #我在这里
  
      if ($http_host ~ "^sojson.com$") {
  
                rewrite^(.*)    http://www.sojson.com$1 permanent;
  
      }
  
      location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ {
  
                access_log off;
  
                expires 7d;
  
      }
  
      location ~* \/(sitemap|robots)\.(html|txt|xml|xsl)$ {
  
                root /data/www/sojson.com/sitemap;
  
      }
  
      location / {
  
                proxy_set_header Host $host;
  
                proxy_set_header X-Real-IP $remote_addr;
  
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  

  
                if ($host ~* www\.sojson\.com) {
  
                        proxy_passhttp://www.sojson.com:8888;
  
                }
  
                if ($host ~* admin\.sojson\.com) {
  
                        proxy_passhttp://admin.sojson.com:8888;
  
                }
  

  
      }
  
}


页: [1]
查看完整版本: Nginx重定向配置