У меня есть NodeJS сервер с NGINX установлен Я построил простую страницу, но какой-то файл получает 404 & 403, и я не знаю, почему Наверное что-то глупо: //Nginx и nodejs 404 и 403 для некоторых файлов
Спасибо большое:)
Это моя страница:
<!DOCTYPE html>
<html>
<head>
<title>Dummy Angular App</title>
<link rel='stylesheet' href='/resources/stylesheets/style.css' />
<script src="/angular/angular.js"></script>
<script src="/angular-route/angular-ui-router.js"></script>
</head>
<body>
<h1>Dummy Angular App</h1>
<p>No Angular Yet!</p>
<script src="/resources/javascripts/app.js"></script>
</body>
</html>
У меня есть по умолчанию NodeJS дерево:
/myApp
--------->/app
--------->/node_modules
-------------->/angular
-------------->/angular-ui-router
--------->/public
-------------->/images
-------------->/stylesheets
-------------->/javascripts
Вот мой Nginx конфигурации:
location /angular {
root /srv/www/testapp/node_modules;
try_files $uri $uri/ =404;
}
location /angular-route {
root /srv/www/testapp/node_modules;
rewrite /angular-route /angular-ui-router/release;
try_files $uri $uri/ = 404;
}
location /resources/ {
root /srv/www/testapp/public;
rewrite_log on;
error_log /var/log/nginx/localhost.error_log notice;
rewrite ^/resources/(.*)$ /$1 last;
try_files $uri $uri/ = 404;
}
location/{
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
- /resources/stylesheets/style.css - 404
- /angular/angular.js - Рабочая
- /angular-route/angular-ui-router.js - Запрещенные (те же разрешения, как угловые)
- /resources/javascripts/app.js - 404
а вот мой журнал (и, кажется, что переписывание работает):
2016/03/04 03:00:07 [notice] 9334#0: *14 "^/resources/(.*)$" matches "/resources/stylesheets/style.css", client: 10.0.0.3, server: webserver.com, request: "GET /resources/stylesheets/style.css HTTP/1.1", host: "www.webserver.com", referrer: "http://www.webserver.com/"
2016/03/04 03:00:07 [notice] 9334#0: *14 rewritten data: "/stylesheets/style.css", args: "", client: 10.0.0.3, server: webserver.com, request: "GET /resources/stylesheets/style.css HTTP/1.1", host: "www.webserver.com", referrer: "http://www.webserver.com/"
2016/03/04 03:00:07 [notice] 9334#0: *18 "^/resources/(.*)$" matches "/resources/javascripts/app.js", client: 10.0.0.3, server: webserver.com, request: "GET /resources/javascripts/app.js HTTP/1.1", host: "www.webserver.com", referrer: "http://www.webserver.com/"
2016/03/04 03:00:07 [notice] 9334#0: *18 rewritten data: "/javascripts/app.js", args: "", client: 10.0.0.3, server: webserver.com, request: "GET /resources/javascripts/app.js HTTP/1.1", host: "www.webserver.com", referrer: "http://www.webserver.com/"
2016/03/04 03:00:07 [notice] 9334#0: *16 "^/resources/(.*)$" matches "/resources/javascripts/app.js", client: 10.0.0.3, server: webserver.com, request: "GET /resources/javascripts/app.js HTTP/1.1", host: "www.webserver.com", referrer: "http://www.webserver.com/"
2016/03/04 03:00:07 [notice] 9334#0: *16 rewritten data: "/javascripts/app.js", args: "", client: 10.0.0.3, server: webserver.com, request: "GET /resources/javascripts/app.js HTTP/1.1", host: "www.webserver.com", referrer: "http://www.webserver.com/"
Почему вы используете 'last' директиву вместо' break'? –