1

I use the following configuration for my domain:

    server_name example.com www.example.com;

    location / {

  proxy_set_header        Host $host;
  proxy_set_header        X-Real-IP $remote_addr;
  proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header        X-Forwarded-Proto $scheme;

    proxy_pass          http://localhost:9999;
    proxy_read_timeout  90;
  }

This works fine and lets me access the service hosted on port 9999 with my domain. However, the service redirects me to ./index.html and I'd like to remove the index.html from the URL. I already tried adding rewrite ^(.*)/index.html$ $1 permanent;

However that leads to me not being able to access the website anymore "The page isn’t redirecting properly"

Klausar
  • 11
  • 2

1 Answers1

1

As a workaround you can try to add index.html to your upstream request when your site get a / request:

location / {
    rewrite                 ^/$ /index.html break;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_pass              http://localhost:9999;
    proxy_read_timeout      90;
}

To append index.html to all URIs ended with slash:

    rewrite ^(.*)/$ $1/index.html break;
Ivan Shatsky
  • 2,726
  • 2
  • 7
  • 19