0

I have a problem with nginx configuration. Everything worked fine in Docker, but I had to resign from Docker, and things started to happen.

Actually I get an 500 internal server error when trying to use my app.

I have copied the contents of dist folder (not the whole folder) to /usr/share/nginx/html.

My nginx.conf looks like this:

server {
   listen         443 ssl;
   server_name    localhost;
   ssl_certificate /usr/share/nginx/cert.pem;
   ssl_certificate_key /usr/share/nginx/key.pem;
   # add Strict-Transport-Security to prevent man in the middle attacks
   add_header Strict-Transport-Security "max-age=31536000" always;

  root   /usr/share/nginx/html;
  index  index.html index.htm;
  include /etc/nginx/mime.types;

  gzip on;
  gzip_min_length 1000;
  gzip_proxied expired no-cache no-store private auth;
  gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

  location / {
    try_files $uri /index.html;
  }

  location /api {
        proxy_pass http://localhost:8080/api;
        proxy_set_header Host $host;
        proxy_redirect          off;
        proxy_set_header        X-NginX-Proxy true;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

The error I get is:

2019/07/09 16:32:42 [error] 7539#7539: *13 rewrite or internal 
redirection cycle while internally redirecting to "/", client: 
172.18.34.217, server: localhost, request: "GET / HTTP/1.1", host: 
"172.17.63.62"

What am I doing wrong?

I have went through nany questions like this on serverfault, but I havent found anything that could solve my problem...

EDIT:

I have also found another error:

stat() "/usr/share/nginx/html/index.html" failed (13: Permission 
denied), client: 172.18.34.217, server: localhost, request: "GET 
/index.html HTTP/1.1", host: "172.17.63.62"

What permissions to the files should I set?

Actually they look like this (just an example, the file list is longer):

-rw-r--r--. 1 user user  12K 07-09 16:22 index.html
drwxr-xr-x. 3 user user   17 07-09 16:22 assets
hc0re
  • 101
  • 1
  • 3

0 Answers0