Reputation: 121
I cannot figure out why this error is happening: "rewrite or internal redirection cycle while internally redirecting to "/index.html"" in nginx.conf
user www-data; worker_processes auto; pid /run/nginx.pid;
events { worker_connections 768; # multi_accept on; }
http {
sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off;
# server_names_hash_bucket_size 64; # server_name_in_redirect off;
include /etc/nginx/mime.types; default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE #ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log;
gzip on; gzip_disable "msie6";
upstream api { server 127.0.0.1:8080; }
server { listen 0.0.0.0:80; root /open-ethereum-pool/www/dist; index index.html index.htm;
server_name localhost;
location /api { proxy_pass http://api; }
location / { try_files $uri $uri/ /index.html; }
}
}
Upvotes: 12
Views: 33005
Reputation: 1
I encountered the same issue, which was caused by an incorrect application root path leading to Nginx not being able to locate the index.html file. The problem was resolved after modifying the configuration.
location / {
root /var/www/fe;
index index.html index.htm;
try_files $uri /index.html;
}
Upvotes: 0
Reputation: 1
On my side the sites-available in path
/etc/nginx/sites-available/project-name
did not have a linked in file in the sites-enabled in path.
/etc/nginx/sites-enabled/project-name
Creating this file on the sites-enabled by running the command fixed my issue
ln -s /etc/nginx/sites-available/project-name /etc/nginx/sites-enabled/project-name
Upvotes: 0
Reputation: 31
Please check this directory ;
/etc/nginx/sites-enabled (Debian dist.)
there is file that named as default and this file linked to your website conf. even you change your nginx_conf
this file be valid for nginx server
Upvotes: 0
Reputation: 814
In my case, I got that error because index.html
file was missing at that root directory.
After I added index.html
file, it started working normally.
Upvotes: 0
Reputation: 767
Most of the time You would want to resort to a fancy 404 not just default nginx error page.
Change
try_files $uri $uri/ /index.html;
To
try_files $uri $uri/ /error.html;
Obviously you will have to place this error.html in your root directory, or even
try_files $uri $uri/ /error404/error.html;
Upvotes: 1
Reputation: 146630
The issue is related to your config
server {
listen 0.0.0.0:80;
root /open-ethereum-pool/www/dist;
index index.html index.htm;
server_name localhost;
location /api {
proxy_pass http://api;
}
location / {
try_files $uri $uri/ /index.html;
}
}
Change
try_files $uri $uri/ /index.html;
to
try_files $uri $uri/ /index.html =404;
This will make sure that when even index.html
in not there you get a 404 and not a internal redirection cycle
Currently what is happening is below when you browse /index.html
It becomes
try_files /index.html /index.html/ /index.html;
Now if /index.html
doesn't exist then your fallback option (last parameter for try_file) is /index.html
. This creates internal redirection cycle. So create the index.html file and the use try_files below way to avoid such issues
try_files $uri $uri/ /index.html =404;
Upvotes: 22