Ubuntu 16.04 中 Nginx 的自签名 SSL 证书和授权(HTTP 错误 403)

Ubuntu 16.04 中 Nginx 的自签名 SSL 证书和授权(HTTP 错误 403)

我已经关注Nginx 自签名 SSL 证书的链接。我的 Nginx 配置如下:

server {
listen 80;
server_name myMachineIP;
return 302 https://$server_name$request_uri;

access_log /var/log/nginx/mysite.access.log;
error_log /var/log/nginx/mysite.error.log;
location / {
    proxy_pass http://127.0.0.1:8000;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static {
    alias /home/users/mysite/app/static;
}

}

server {

  # SSL configuration

   listen 443 ssl http2 myMachineIP;
   listen [::]:443 ssl http2 myMachineIP;
   include snippets/self-signed.conf;
   include snippets/ssl-params.conf;
}

但我还是

Access to 192.168.1.xxx was denied You don't have authorization to view this page. HTTP ERROR 403

这个配置有什么问题?任何帮助都将不胜感激。

答案1

第一个服务器块执行,return 302因此location它包含的块被忽略。

第二个服务器块不包含location任何块,这可能解释了 403 响应。

location将块从第一个服务器块移动到第二个服务器块。

这个文件了解更多信息。

相关内容