I'd like to return the response code 403 on Nginx.

Asked 2 years ago, Updated 2 years ago, 41 views

403 returns, but I'm not sure how it works

Tried

conf file

 error_page403/hoge.php;

hoge.php

<?php
http_response_code(403);

Browser Screen

403 Forbiddenginx/1.12.2

Q1. Where is "403 Forbiddenginx/1.12.2" set?
·Are you calling any screen?
·Or just displaying the text dynamically??
"·Is it possible to hide ""nginx"" and ""version"" on this screen?"
n I checked nginx.conf, but there is nothing about 403

Q2. Where is "403 Forbiddenginx/1.12.2" set?
·How can I call this screen directly?
"·Currently, the flow says ""intentionally set page 403"" → ""custom page specified in error_page 403"" → ""403 Forbidden nginx/1.12.2"", but how can I call this ""403 Forbidden"" screen directly from ""403 Set Page"" instead of via custom page?"

Question Background
"·I am not particular about ""403 Forbidden"", so I would like to set it as easily as possible without specifying it for each server."
"·If Nginx itself has the function of displaying ""403 Forbidden"", I would like to use it

"

nginx

2022-09-30 11:01

1 Answers

"What happens when a 403 error occurs?"
1) An error_page403/hoge.php; (meaning show /hoge.php when 403 errors occur) configuration causes hoge.php to run.
2) In hoge.php, http_response_code(403); displays the HTTP response of 403 ("403Forbiddingginx/1.12.2").
 The reason it appears is because the function http_response_code is created like that.

==
"Is it possible to hide nginx and version on this screen?"
Hoge.php determines what you want to see.If you only want to see "403 Forbidden", you can use hoge.php as follows:

{php?
   echo('403Forbiden')


2022-09-30 11:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.