大网数据广告活动
服务器运维问答

Nginx query param in location

· 52CE 我爱测

I have a location block in my nginx server, if i access using https://example.com/login/ display my alias folder value correctly, but if i use as follow: https://example.com/login/?param1=value1 , i have a Error 400 bad request l…

问题原文

原帖链接 · mleaf · CC BY-SA 4.0

I have a location block in my nginx server, if i access using https://example.com/login/ display my alias folder value correctly, but if i use as follow: https://example.com/login/?param1=value1, i have a Error 400 bad request

location ~ /login/ {
    alias /var/www/app_one/dist/;
    try_files $uri$args $uri$args/ /var/www/app_one/dist/index.html;
  }

已采纳解答

原帖链接 · Tero Kilkanen · CC BY-SA 4.0

try_files is used to refer to physical files on the filesystem. With your configuration, when requesting /login/?param1=value1, nginx tries to find file /var/www/app_one/dist/login/param1=value1.

Depending on the actual contents of param1 and value1, nginx might respond with 400 Bad request, because some characters are not allowed when accessing files.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-10-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。