Deploy nodejs app on ecs - node.js

I'm try launch Nodejs app on alibabacloud ecs with using nginx.
my app is in /var/www/html/ar_exp folder
When I runnode app then app listen localhost:8080
my nginx default config:
`
server {
listen 80;
server_name mydomain.com;
location / {
proxy_pass http://localhost:8080;
}
}
`
When I check from my ecs server via curl mydomain.com or via wget mydomain.com response is correct from nodejs app. But when i check it in browser then: ERR_connection_timed_out.
For all files in nodejs app folder () i set the following settings:
chown -R www-data:www-data /var/www/
and 755 for all files
what else would I check?

Website inaccessibility from the ECS can be due to following reasons.
OS firewall: Make sure that the application OS firewall(ufw) settings are properly configured to allow communication to the application port.
VPC Security Group: Make sure that the security group setting is applied and required communication port is configured.Details to configure security group

Related

How to reverse proxy to a Node.js app in a domain subfolder with Nginx on CentOS?

I have a domain https://ytdownvideo.com running a WordPress website.
I want to run a Node.js app in a subfolder on the same domain, as follows: https://ytdownvideo.com/youtube/
I am using Nginx on CentOS 7 x64.
How can I configure Nginx to reverse proxy to the Node.js app when navigating to this subfolder?
First, you will need to run your Node.js app on a different and unused port. For example, 3000.
Then, add the following to your nginx configuration:
location ~ ^\/youtube.*$ {
proxy_pass http://localhost:3000;
port_in_redirect off;
}
Restart nginx with:
sudo systemctl restart nginx

How to setup Nginix Docker Reverse proxy

I am trying to use Nginix reverse proxy container for my web application(another docker container) which runs on non standard port ,
unfortunately I cannot edit my web application container as its developed by some vendor , so I have a plain request that I need to setup nginx as frontend with 80/443 and forward all requests to 10.0.0.0:10101(web app container).
I had tried jwilder/nginx proxy and default docker nginx container not able to get the right configurtaion .any lead would be great.
At the moment I haven't shared any conf files , I can share it on demand. here is the environment details
OS - Ubuntu
Azure
Use proxy_pass nginx feature
Assuming you have both containers linked and the web app container's name is webapp use this configuration on nginx container
upstream backend {
server webapp:10101;
}
server {
listen 80;
location / {
proxy_pass http://backend;
}
}
NOTE: please note that I am skipping some configurations as this is just an example
Put the configuration in nginx.conf file and then deploy the container like this
docker run -d -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf -p 80:80 nginx
Then you'll be able to access your webapp on http://locahost

Can't access my nodeJS web app hosted on AWS EC2 through browser

I have hosted a nodeJS application on AWS ec2 instance which I can access through ssh but not through my browser i.e, http.
There is no error logged on the console it only shows the following message in the browser:
"unable to connect"
I am aware about security groups and checked them twice I've included http as well as https properly. Please help
Did you configure a web server to direct the requests from the AWS URL to the nodejs application you are running?
Try checking out nginx (https://www.nginx.com/), its really easy and fast to cofigure.
Here is a minimal configuration template:
server {
listen 80;
server_name <aws-url>;
location / {
proxy_pass 127.0.0.1:<node-port>;
}
}

Nginx is refusing to connect on AWS EC2

I'm trying to use nginx to setup a simple node.js server, I'm running the server in background on port 4000, my nginx config file is
server {
listen 80;
listen [::]:80;
server_name 52.53.196.173;
location / {
include /etc/nginx/proxy_params;
proxy_pass http://127.0.0.1:4000;
}
}
I saved it in /etc/nginx/sites-available and also symlinked it to sites-enabled, the nginx.conf file has the include line already to load files from sites-enabled, then i restarted the service using
sudo service nginx restart
I tried going to 52.53.196.173 and it refuses to connect, however going to 52.53.196.173:4000 with port 4000 it is working, but I'm trying to make it listen on port 80 with nginx, i tried putting my .ml domain as server_name and no luck, and i have the IP 52.53.196.173 as the A record in the domain dns settings, and I'm doing this on an AWS EC2 Instance Ubuntu Server 16.04, i even tried the full ec2 public dns url no luck, any ideas?
Edit: I solved it by moving the file directly in sites-enabled instead of a symlink
There is few possible things. First of all you need to verify that nginx server is running & listening on port 80. you can check the listening ports using the following command.
netstat -tunlp
Then you need to check your server firewall & also the selinux policies. ( OR disable selinux for test )
Then you need to verify that AWS security group configured to access the http/https connections on port 80.
PS : Outputs from the following command & configurations will be helpful for troubleshooting.
netstat -tunlp
sestatus
iptables -L
* AWS Security Group Rules
* Nginx configurations ( including main configuration if changed )
P.S : OP fixed the problem by moving the config file directly into site-enabled directory. maybe, reefer the comments for more info if you are having the same issue.
Most probably port 80 might not be open in your security group or nginx is not running to accept the connections. Please post the nginx status and check the security group
check belows:
in security group, add Http (80) and Https (443) in inbound section with 0.0.0.0 ip as follow:
for 80 :
for 443 :
in Network ACL, allow inbound on http and https. outbound set custom TCP role as follow:
inbound roles:
outbound roles:
assign a elastic ip on ec2 instance, listen to this ip for public.

Azure App Service getting Error 404 when redirected via NGINX

I created a VM, port 80 is open and installed NGINX on it.
I created 2 App Services which can be accessed via x1.azurewebsites.net and x2.azurewebsites.net
I configured the VM to act as an load balancer but when redirecting the traffic I get the following: https://i.gyazo.com/b94bed9c90d3b0f0c400c83f762f0544.png
I am not using my own domain. Does someone know what the issue could be?
I got the following configurations:
upstream backend {
server xx.azurewebsites.net;
server xxx.azurewebsites.net;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
server_name_;
location / {
proxy_pass http://backend;
}
}
Azure App Service uses cookies for ARR (Application Request Routing). You have to make sure that your NGinx reverse proxy configuration pass the correct cookie / header to your web app.
The other possibility (to make sure the behavior comes from ARR) is to disable it: https://azure.microsoft.com/en-us/blog/disabling-arrs-instance-affinity-in-windows-azure-web-sites/

Resources