Templates 当NGINX关闭或重新加载时,如何加载HTML模板?
大家好,我正在试图找到一种方法来加载Templates 当NGINX关闭或重新加载时,如何加载HTML模板?,templates,nginx,Templates,Nginx,大家好,我正在试图找到一种方法来加载html,当我构建应用程序时,它会显示服务器关闭或类似的内容 现在,每当我构建后端和前端时,如果我访问该站点,我都会在几秒钟内看到以下模板: 我想自定义该页面,或者显示另一个模板,上面写着:服务器当前关闭或构建 我的nginx.conf如下所示。我应该将403.html模板的加载位置放在哪里?:我认为这需要在构建文件夹之外,因为403页面在构建时出现 server { # [ASK]: is this what's causing the problem
html
,当我构建应用程序时,它会显示服务器关闭
或类似的内容
现在,每当我构建后端和前端时,如果我访问该站点,我都会在几秒钟内看到以下模板:
我想自定义该页面,或者显示另一个模板,上面写着:服务器当前关闭
或构建
我的nginx.conf
如下所示。我应该将403.html模板的加载位置放在哪里?:我认为这需要在构建文件夹之外,因为403页面在构建时出现
server { # [ASK]: is this what's causing the problem ?
root /home/smiling/smiling-frontend/website/build; ## development build
index index.html;
server_name frontend.develop.smiling.be; ## development domain
charset utf-8;
gzip on;
gzip_vary on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
text/plain
text/css
text/js
text/xml
text/javascript
application/javascript
application/x-javascript
application/json
application/xml
application/xml+rss;
location / {
try_files $uri $uri/ /index.html;
}
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|svg|woff|woff2|ttf)\$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
location ~* \.(?:css|js)\$ {
expires 7d;
access_log off;
add_header Cache-Control "public";
}
location ~ /\.well-known {
allow all;
}
location ~ /\.ht {
deny all;
}
add_header Access-Control-Allow-Origin '*/';
add_header Access-Control-Allow-Headers 'origin, x-requested-with, content-type, accept, authorization';
add_header Access-Control-Allow-Methods 'GET, POST';
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/backend.develop.smiling.be/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/backend.develop.smiling.be/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
谢谢你的最后一句话有点前后矛盾。。。你不喜欢做什么,但还是想做同样的事情
您可以定义自己的页面或字符串,以便在出现错误时提供服务:
error_page 403 /403.html;
location = /403.html {
internal;
return 403 "Server Down at the moment"; # <- this could also contain an HTML string if your nginx defaults to text/html as content type.
}
error_第403/403.html页;
location=/403.html{
内部的;
返回403“此时服务器已关闭”#谢谢,我更正了最后一句。这确实让人困惑。这个设置,你是将它们添加到nginx配置文件还是确切位置?谢谢你将它添加到你的nginx.conf
服务器块。我用我的nginx.conf更新了我的anwer。我想加载403.html。但是我在理解放在哪里有问题。很抱歉是的,所有这些都是新的。顺便说一下,我正在构建一个react应用程序。