然后使用error_page指令配置NGINX以使用自定义错误页面。如图所示,在/etc/nginx/snippets/下创建一个名为custom-error-page.conf的配置文件。$ sudomkdir /etc/nginx/snippets/$ sudovim /etc/nginx/snippets/custom-error-page.conf 向其中添加以下行:error_page 404403500503 /error-page.html;location = /error-...
如图所示,在/etc/nginx/snippets/下创建一个名为custom-error-page.conf的配置文件。 $ sudo mkdir /etc/nginx/snippets/ $ sudo vim /etc/nginx/snippets/custom-error-page.conf 向其中添加以下行: error_page 404 403 500 503 /error-page.html;location = /error-page.html { root /var/www/html; in...
如图所示,在下创建一个名为custom-error-page.conf的配置文件。 $ sudo mkdir /etc/nginx/snippets/$ sudo vim /etc/nginx/snippets/custom-error-page.conf 向其中添加以下行: error_page 404 403 500 503 /error-page.html;location = /error-page.html {root /var/www/html;internal;} 每次NGINX遇到任何...
server {listen 80;server_name example.com;root /var/www/example.com;error_page 404 /custom_404.html;location = /custom_404.html {internal;}} 在这个配置中,我们告诉Nginx当遇到404错误时,使用/custom_404.html页面。location块中的internal指令确保这个页面只能通过内部重定向访问,而不能直接从外部访问。
First, create the HTML file for your custom 404 page using nano or your preferred text editor: sudo nano /usr/share/nginx/html/custom_404.html Copy Insert your custom error into your created file: Error 404: Not found :-( I have no idea where that file is, sorry. Are yo...
在http块中定义的error_page指令可用于处理所有虚拟主机的错误。 需求 实现一个自定义错误页面,页面中有个图片展示 实现 大致结构如下 代码语言:javascript 复制 server{listen80;server_name your_domain.com;error_page404/error/custom_404.html;location=/custom_404.html{alias/path/to/your/site;}# 其他配置...
-name:nginx-error-serverimage:quay.io/kubernetes-ingress-controller/custom-error-pages-amd64:0.3ports:-containerPort:8080# Setting the environment variable DEBUG we can see the headers sent# by the ingress controller to the backend in the client response.# env:# - name: DEBUG# value: "true"...
这样的提示界面 并不友好。在 Nginx 的主配置文件中,给出了以下的处理方式。 error_page 500 502 ...
NGINX 404 Error Page Having a dynamic site with such an ugly-looking page will reduce the UI/UX impression of your site. However, NGINX provides you with the option to configure a custom error page for your site. To do that, you need to create a custom HTML page and specify it in th...
error_page404/custom_404.html;location=/custom_404.html{root/usr/share/nginx/html;internal;}...}} 通常,我们不必在新的位置块中设置root,因为它与服务器块中的根匹配。但是,我们在此明确说明,即使我们将常规Web内容和关联文档根目录移动到其他位置,也会提供错误页面。