私は私のMac上で角度2アプリを開発し、それがローカルで実行webseverとしてnginxのを使用していました。これをAWS EC2インスタンスにデプロイするようになりました。これはLinux Red Hat 7のインスタンスです。nginxの404またはデフォルトページ
私はnginxのをインストールし、SERVER_NAME値とルートを変更することを確認して、私のMacから私の作業の設定をコピーしたが、私は、デフォルトのnginxのページまたは404エラーが出るのいずれかました。
私は/var/www/dist
でセットアップ私のアプリを持っているとdistの中にそのパスとファイルへchmod 755
権限を与えられました。以下は私の設定です(server_nameの山括弧は実際の設定ではありませんが、私はこのポストのインスタンス名を隠しています)。
myhost/index.html
またはmyhost/someapppath
のすべてが404を返します。myhost/
を使用すると、デフォルトのnginxページが返されます。私はhtmlディレクトリを作成してそこにファイルを置くことによって私のルートをチェックしようと試みたこともありますが、それでも取り上げられることはありません。私は各設定後もnginxを再起動しましたが、まだ同じ取得します。
アイデア?
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;
server_names_hash_bucket_size 128;
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;
server {
listen 80;
server_name <hiding instance for this post>.ap-southeast-2.compute.amazonaws.com;
root /var/www/dist;
#charset koi8-r;
#access_log logs/host.access.log main;
location/{
index index.html index.htm;
try_files $uri $uri$args $uri/index.html /index.html =404;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
#include /etc/nginx/conf.d/*.conf;
}
UPDATE
再び設定いじり、その後、私は今、以下を参照してください。エラーログを見た後:
2017/11/16 17:12:14 [crit] 23126#23126: *2 stat() "/var/www/dist/index.html" failed (13: Permission denied)
これは、より理にかなっています。私はsudo chown nginx: var/
とsudo chown -R nginx: /var/www
をnginxユーザーのために実行し、nginxを再起動しましたが、私は引き続き許可を拒否されます。パーミッションを正しく設定していますか?
私はお手伝いをしたいと思います!インデックスを/ distに配置しましたか?また、サーバー名はユーザーが要求するURLである必要があります – Colton
@Colton index.htmlは/ distフォルダにあり、server_nameはサイトにアクセスするために使用するパブリックDNS名です。奇妙なことに、すべてがローカルで動作します。 – rossco