Reputation: 35
I have deployed my project(angular) on nginx its running on port 4210. I am using AWS ec2 instance. when I am trying to run my project on browser its giving me 500 internal server error.Can you please tell me where I am going wrong this is my first time.Thank You in advance
nginx -t
is giving success and angular server is also working
Default server configuration(sites-available)
server {
listen 80;
listen [::]:80;
listen 127.0.0.1;
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
send_timeout 600s;
set $frontend "http://localhost:4210";
set $apiBackend "http://localhost:5002";
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass $frontend/$uri$is_args$args;
proxy_redirect off;
}
location /api {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass $apiBackend/$uri$is_args$args;
proxy_redirect off;
}
}
my nginx.conf file
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##enter code here
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
resolver 127.0.0.1;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
logs
2019/09/05 18:47:47 [error] 7090#7090: send() failed (111: Connection refused) while resolving, resolver: 127.0.0.1:53
2019/09/05 18:47:47 [error] 7090#7090: send() failed (111: Connection refused) while resolving, resolver: 127.0.0.1:53
Upvotes: 1
Views: 5425
Reputation: 3198
Here're some options to solve that:
sudo apt-get install dnsmasq
to have local DNS server running on 127.0.0.1
(similar to [1])resolver 169.254.169.253
to use default AWS DNS server for EC2 instances in VPC [2]Here's a link to AWS knowledge center regarding dnsmasq [3]
[1] https://stackoverflow.com/a/8559797/1224211
[2] https://docs.aws.amazon.com/vpc/latest/userguide/vpc-dns.html#vpc-dns-support.
[3] https://aws.amazon.com/premiumsupport/knowledge-center/dns-resolution-failures-ec2-linux/
Upvotes: 1