返回

Nginx常用配置

重定向所有错误页面

1
2
3
4
5
6
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 @error_page;

location @error_page {
    internal;
    return 404;
}

临时维护页面

1
2
3
4
5
rewrite ^(.*)$ /maintenance.html break;

location = /maintenance.html {
    root /var/www/html;
}

转发端口

1
2
3
4
5
6
stream {
    server {
        listen 2222;
        proxy_pass 192.168.1.1:22;
    }
}

隐藏版本号

1
server_tokens off;
Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy