nginx 通过外网服务器泛域名配置映射到内网端口或者泛地址
标签搜索

nginx 通过外网服务器泛域名配置映射到内网端口或者泛地址

loong
2019-07-26 / 0 评论 / 4,882 阅读 / 正在检测是否收录...



nginx 通过外网服务器泛域名配置映射到内网端口或者泛地址。


配置示例如下:


server
{
      listen 80;
      server_name *.i.weitip.com;
      index index.php index.html index.htm default.php default.htm default.html;
      root /www/wwwroot/weitip.com/frps;

      location / { 
		  # 泛域名开始配置
		  if ( $host ~* (.*)\.(.*)\.(.*)\.(.*) ) {
		  set $domain $1; #获取当前的 域名前缀
		  }

		  resolver 114.114.114.114;

		  set $url "http://$domain.weitip.com:8080"; 

		  proxy_pass $url; 
          proxy_set_header   Host    $host; 
          proxy_set_header   X-Real-IP   $remote_addr; 
          proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for; 
          } 

      access_log  /www/wwwlogs/frps.weitip.com.log;
      error_log  /www/wwwlogs/frps.weitip.com.error.log;
  }



32