我一直在尝试在运行Ubuntu 20.04的WSL2上设置Nginx。我几乎完成了整个站点设置。当我访问http:// localhost时,它正在工作。但我希望它位于http://app.test上。所以我将其添加到主机并尝试,它抛出403 Forbidden错误。我没有更改nginx.conf
中的任何内容。这是我到目前为止所拥有的:
服务器块
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/app.test;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
权限
/var/www/html/app.test
文件夹属于www-data:www-data
用户和组。
主机
我已经在Windows主机和Ubuntu主机中添加了以下内容
127.0.0.1 app.test
发现
127.0.0.1 - - [05/Nov/2020:00:07:09 +0400] "GET / HTTP/1.0" 403 564 "-" "Mozilla/5.0 (Windows NT 10.0;..."
::1 - - [05/Nov/2020:00:01:13 +0400] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0;...
http://localhost
得到200 OK,但http://127.0.0.1
却得到403禁止谢谢!