1Panel-dev / 1Panel-dev/1Panel

[Feature] If you stop the website and access the other paths of the website, you will report an error of 404. Can you add a common location block to match all URL requests?

Open
#8,261 4 comments 0 reactions 1 assignee View on GitHub

@wanghe-fit2cloud is already working on this.

Since Mar 26, 2025.

type: optimization
Dominant language
Go
Stars
37k
Forks
3.4k
Avg merge
9h 16m
Merged PRs (30d)
105

Description

1Panel Version

v1.10.28-lts

Please describe your needs or suggestions for improvements

1 把网站暂停 访问主页 xxx.com 显示抱歉网站已暂停

2 访问xxx.com/abc/index.html 页面显示4040

如果能匹配所有的情况下就好了 无论访问什么都显示 网站已暂停页面

Please describe the solution you suggest

可以在暂停网站后增加一行配置

location / { try_files /index.html =404; }

`
location /:这是一个通用的 location 块,匹配所有的 URL 请求。
try_files /index.html =404:该指令会尝试查找 /index.html 文件。如果文件存在,则返回该文件;如果文件不存在,则返回 404 错误。在你的情况下,由于 root 已经设置为 /usr/share/nginx/html/stop,所以实际上会查找 /usr/share/nginx/html/stop/index.html 。

`

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.