2021/02/23 18:50:45 [error] 3476#3476: *1 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 192.168.0.50, server: _, request: "GET /search HTTP/1.1", host: "192.168.0.94", referrer: "http://192.168.0.94/"
我正在尝试使用node.js制作一个网站,因为我想在将来实现其他应用程序。我可以在我的电脑上获得子目录,但当我试图使用任何东西,我会得到这个错误。
这是我的配置:
server {
listen 80;
server_name _;
error_log /var/log/nginx/personalsite.error.log;
root /var/www/html/;
index search.html;
location / {
proxy_pass http://localhost:3000;
try_files $uri $uri/ =404;
}
location ^~ /search/ {
alias /var/www/html/views/;
}
location ^~ /results/ {
alias /var/www/html/views/;
}
}
我的app.js:
const express = require('express');
const path = require('path');
// Init App
const app = express();
// Load View Engine
app.use('/css', express.static(path.join(__dirname, 'css')));
app.use('/js', express.static(path.join(__dirname, 'js')));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// Web Routes
app.engine('html', require('ejs').renderFile);
app.use(express.urlencoded({extended: true}));
app.get('/', (req, res) => {
res.render('index.html');
});
app.get('/search', (req, res) => {
res.render('search.html');
});
app.get('/results', (req, res) => {
res.render('results.html');
});
app.get('/found', (req, res) => {
res.render('found.html');
});
app.get('/player', (req, res) => {
res.render('player.html');
});
// Start Server
app.listen('3000', () => {
console.log('Listening on port 3000!');
});
如果你知道为什么这个问题会对我有帮助,谢谢!
发布于 2022-02-11 11:00:28
试着取代
try_files $uri $uri/ =404;
至
try_files $uri $uri/ index.html;
阅读有关Nginx rewrite or internal redirection cycle while internally redirecting to "/index.html"的更多信息
https://stackoverflow.com/questions/66339531
复制相似问题