Home  >  Q&A  >  body text

server - nginx configuration: access static files 403 forbidden

nginx configuration:

    server {
            listen 443;
            server_name localhost;
            ssl on;
            ssl_certificate /home/attolee/sslkey/example.crt;
            ssl_certificate_key /home/attolee/sslkey/example.key;
            ssl_session_timeout 5m;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_ciphers ALL:!ADH:!EXPORT56:-RC4+RSA:+HIGH:+MEDIUM:!EXP;
            ssl_prefer_server_ciphers on;

            location / {
                    root /home/a;
                    index index.html;
            }

            location /b/ {
                    root /home/a;
                    index b.html;
            }
   }

I want

  1. https://host/ can access /home/a/index.html,

  2. https://host/b can access /home/a/b/b.html,

Now 1 is successful, 2 is not successful, 403 Forbidden, may I ask, what is the problem with the configuration?

renew

More detailed problem description: 403 forbidden of nginx in ubuntu

滿天的星座滿天的星座2713 days ago411

reply all(3)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 17:23:07

    root需要xPermissions:

    d--------x  2 attolee attolee  4096 11月  2 21:54 hi/

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-16 17:23:07

    Both of the answers above are wrong!
    Let me tell you:
    The location below should be changed to
    location /b/ {

                    root /home/a/b;
                    index b.html;
            }

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 17:23:07

    Reverse the order of the two locations
    In addition, according to your configuration, it should behttps://host/b/能否访问到/home/a/b/b.html

    reply
    0
  • Cancelreply