我正在使用角度爲2的應用程序,nginx和docker。每次我重裝與/網站它給了我一個頁面404.我的服務器塊貌似現在這種權利:nginx.conf中的try_files不起作用
server {
listen 0.0.0.0:80;
listen [::]:80;
root /var/www/project/html;
index index.html;
server_name project.com;
location/{
try_files $uri $uri/ /index.html;
}}
我已經嘗試了很多,看到了一切其他計算器的問題,並嘗試各種可能性。但沒有任何工作。有人可以幫忙嗎?
UPDATE: 整個nginx.conf:
user nginx;
worker_processes auto;
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;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
啓用站點-/默認:
server {
listen 0.0.0.0:80;
listen [::]:80;
root /var/www/project/html;
index index.html;
server_name project.com;
location/{
try_files $uri $uri/ /index.html;
}}
而且Dockerfile:
FROM nginx
COPY ./docker/sites-enabled /etc/nginx/sites-enabled
COPY ./docker/nginx.conf /etc/nginx/nginx.conf
COPY ./dist /var/www/project/html
COPY ./dist /usr/share/nginx/html
EXPOSE 80
你有沒有錯誤日誌? – Moema
@Moema只有錯誤日誌:'無法加載資源:服務器響應狀態爲404(未找到)'。沒有其他的。 – vaman
我的意思是你可以在你的nginx.conf中配置的Nginx錯誤日誌(請參閱https://www.nginx.com/resources/admin-guide/logging-and-monitoring/)我認爲,默認情況下它們位於/ var/log/nginx/ – Moema