私はang 2のアプリケーションであるnginxとdockerを使っています。毎回私はそれが私に与え/サイトでページをリロードしています私のサーバブロックは今、この権利のように見える404:私は多くのことを試してみましたが、他のすべてのstackoverflowの質問を見ていると、すべての可能性を試してみました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:あなたのnginx.confで
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(Not Found)のステータスで応答しました'。他に何もない。 – vaman
Nginxのエラーログは、nginx.confで設定できます(https://www.nginx.com/resources/admin-guide/logging-and-monitoring/を参照してください)。デフォルトでは/ var/log/nginx/ – Moema