我正在构建一个我想使用Nginx服务的vue.js应用程序。但是,它失败并显示错误ERR_TOO_MANY_REDIRECTS
。
在开始时,nginx尝试在外部端口为8000时重定向到端口80。这就是为什么我在配置中添加行absolute_redirect off;
的原因。但是,这只会导致重定向循环:
172.17.0.1 - - [02/Jan/2019:15:24:24 +0000] "GET / HTTP/1.1" 301 169 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
172.17.0.1 - - [02/Jan/2019:15:24:24 +0000] "GET / HTTP/1.1" 301 169 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
172.17.0.1 - - [02/Jan/2019:15:24:24 +0000] "GET / HTTP/1.1" 301 169 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
172.17.0.1 - - [02/Jan/2019:15:24:24 +0000] "GET / HTTP/1.1" 301 169 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
172.17.0.1 - - [02/Jan/2019:15:24:24 +0000] "GET / HTTP/1.1" 301 169 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
172.17.0.1 - - [02/Jan/2019:15:24:24 +0000] "GET / HTTP/1.1" 301 169 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
172.17.0.1 - - [02/Jan/2019:15:24:24 +0000] "GET / HTTP/1.1" 301 169 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
这是/etc/nginx/nginx.conf文件:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile off;
keepalive_timeout 60;
# gzip on;
include /etc/nginx/conf.d/*.conf;
}
这是网站配置:
server {
absolute_redirect off;
port_in_redirect off;
location / {
root /usr/share/nginx/html/;
try_files / /index.html;
}
}
我在这里想念什么?
答案 0 :(得分:0)
try_files / /index.html;
这会循环回到您的位置/
,将其更改为try_files $uri $uri/ /index.html =404;
应该可以解决您的问题