A
A
Alecxandrys2017-10-30 13:01:43
Nginx
Alecxandrys, 2017-10-30 13:01:43

How to host an additional location in nginx?

Good afternoon,
Deployed the server running the application with the following configuration. But the url resource location always returns 404 for requests, although the specified path in the system (Ubuntu) exists along with the content, read rights for all users are registered for both the directory and the files inside it. The application is based on Spring, the tomcat configuration has not changed in any way, the / resource addresses are not used in any way and are not mapped.

server {
  listen          80;
  server_name     <servername> ;
  ssl_dhparam /etc/ssl/certs/dhparam.pem;

    location ~/resource {
<------>root /var/www/html/droid_resource;
<------>autoindex on;
<------>autoindex_exact_size off;
<------>autoindex_localtime on;
    }

    location / {
        proxy_set_header X-Forwarded-Server $host;
<------>proxy_pass http://127.0.0.1:8081;
<------>proxy_set_header X-Forwarded-Proto $scheme;
<------>proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/igarbage.ml/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/igarbage.ml/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot



    if ($scheme != "https") {
        return 301 https://$host$request_uri;
    } # managed by Certbot

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Vlasov, 2017-11-15
@Stanislavvv

It is worth removing the tilde if you want to process /resource separately

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question