小编Gur*_*erz的帖子

防止NGINX移除端口

我想在重写时动态保持服务器名称和端口:假设防火墙将端口 8081 重定向到 80。因此,如果我使用“192.168.1.123/frontend”或“my.domain.tld:8081/”等访问网络服务器前端”我应该重定向到“192.168.1.123/frontend/”或“my.domain.tld:8081/frontend/”

如果我使用普通redirect rewrite ^(.*[^/])$ $1/ permanent;端口并使用端口 8081 访问,则端口被删除。(我已经试过了port_in_redirect off;

我几乎使用默认配置:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;

        server_name _;
        rewrite ^(.*[^/])$ $1/ permanent;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi.conf;
        }
}
Run Code Online (Sandbox Code Playgroud)

谢谢期待! …

port nginx strip url-rewriting

12
推荐指数
1
解决办法
8303
查看次数

标签 统计

nginx ×1

port ×1

strip ×1

url-rewriting ×1