php – 从nginx重定向中删除端口
发布时间:2020-12-13 17:24:21  所属栏目:PHP教程  来源:网络整理 
            导读:我遇到一个问题,网站上的某些重定向包含了代理传递端口,使它们无用.我的配置如下: 物理服务器1: server { server_name example.com www.example.com; location / { proxy_pass http://1.1.1.1:50493; proxy_set_header X-Real-IP $remote_addr; proxy_set_
                
                
                
            | 
                         
 我遇到一个问题,网站上的某些重定向包含了代理传递端口,使它们无用.我的配置如下: 
  
  
物理服务器1: server {
    server_name example.com www.example.com;
    location / {
            proxy_pass              http://1.1.1.1:50493;
            proxy_set_header        X-Real-IP  $remote_addr;
            proxy_set_header        Host "example.com";
    }
} 
 物理服务器2: server {
            listen 50493;
            server_name example.com www.example.com;
            set_real_ip_from    1.1.1.1;
            root /var/www/example.com;
            index index.php index.htm index.html;
            location / {
                    if ($http_host !~ "^example.com"){
                            set $rule_0 1$rule_0;
                    }
                    if ($rule_0 = "1"){
                            rewrite ^/(.*) http://example.com/$1 permanent;
                    }
                            rewrite /[^/]+/([0-9]+)-[^/]+.html http://example.com/showthread.php?t=$1 permanent;
            }
            location ~ .php${
              fastcgi_pass   127.0.0.1:9000;
              fastcgi_index  index.php;
              fastcgi_param  SCRIPT_FILENAME /var/www/example.com$fastcgi_script_name;
              include fastcgi_params;
              fastcgi_read_timeout 600s;
              fastcgi_buffer_size 512k;
              fastcgi_buffers 16 512k;
            }
   } 
 一般来说,浏览工作正常.该网站可以按照人们的预期浏览.但是一些重定向的链接(例如,在登录操作之后),重定向到包含端口50493的链接.所以我们以http://example.com:50493/index.php为例.那样不行.我的问题是,如何删除端口? 据我所知,论坛软件从php会话端口变量获取端口.我已经尝试关闭port_in_redirect,但无济于事.如果有帮助,这里突出显示的问题:http://kb.parallels.com/en/114425是类似的. 谢谢. 解决方法
 它会告诉您如何在您提供的链接中解决问题.更改: 
  
  
  
        <?php echo $VAR->domain->asciiName ?>:<?php echo $OPT['ssl'] ? $VAR->server->webserver->httpsPort : $VAR->server->webserver->httpPort ?>" 至 <?php echo $VAR->domain->asciiName ?>" 您必须在应用程序中而不是在Nginx中修复此问题. 您的应用程序正在生成指向端口50493 like this的链接.除非您要设置通过所有HTML的内容过滤器并使用example.com/path/of替换example.com:50493/path/of/url / url然后你必须在应用程序内修复它. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!  | 
                  
