When you create a directory and access ~ /, 403 error is displayed.
January 10, 2020 02:39AM
When you create a directory and access ~ /, 403 error is displayed.

If you know anything, please let me know.

◎ description
-There is a setting file to which the document root has been added, and if you access "~ /" when creating <hoge_public> directory, a 403 error occur.

-Even if sitemap.xml is placed under the directory, accessing "~ /" will cause a 403 error, and accessing "~ / sitemap.xml" in this state will display the contents of the file normally.

-If the directory is not created even after adding the settings, the top page (@hogehoge) is displayed normally with ~ /

◎error log
The error.log shows dozens of lines of errors that do not exist in the following files, do not refer to the intended location, and the file does not exist there. Since the path of the error is the default path of nginx, the file is not found and it seems that it has fallen back.

/usr/share/nginx/html/hoge.html" failed (2: No such file or directory)

◎ Possible causes
-The configuration file is incorrectly written because it does not refer to the intended location
→ Since you can access it with ”~ /” sitemap.xml, the document root setting is correct and it should work.
・ Authority issues
→ The directories are all directories to the document root and have x, r permissions. I'm wondering if there's no problem with permissions because I can access it in ~ / sitemap.xml.
・ OS setting problem
→ There was information that may be caused by selinux, but it is invalid.

◎settion file
location / {

root /home/hogeuser/DocumentRoot/hoge_public;

add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "POST, GET, OPTIONS";
add_header Access-Control-Allow-Headers "Origin, Authorization, Accept";
add_header Access-Control-Allow-Credentials true;

try_files $uri @hogehoge;


◎ Confirmed points
・Each directory in the document root has x, r permissions
・ Selinux is disabled
・Another configuration file under /etc/nginx/conf.d/ has not been read

◎ Expected behavior
-If you access ”~ /”, @hogehoge (the path of the TOP page is set) will be accessed and displayed normally.
-If you access ”~ / sitemap.xml”, the contents of that file will be displayed

Re: When you create a directory and access ~ /, 403 error is displayed.
January 10, 2020 06:25AM
# try_files $uri @hogehoge;
try_files $uri $uri/ @hogehoge; # modify here
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 62
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready