Access image using url on aws ec2 server - amazon-web-services

I'm working on the AWS EC2 server on which I saved a image on a specific path /var/www/html/uploads/imageName.jpg using FileZila. I want to access that image using url. How can I do that? I have both access read and write in that directory.
below are the security groups
HTTP TCP 80 MyIP
CustomTCPRule TCP 8080 MyIP
SSH TCP 22 MYIP

If you want to access information from a computer via HTTP, then the computer needs to be running a web server.
If it is running a web server, test it by logging into the instance and running:
curl localhost
If this fails, then something is wrong with your web server.

Related

What is the endpoint of the EC2 linux1 instance?

I created an EC2 linux1 instance and I SSH into it. I installed NodeJS and cloned a git repository to the instance. The app is successfully running and connected to the MySQL database instance I created from the RDS. Assume the app name is my-app. What I want is to be able to access the the app on the server.
I tried
- ec2-{Public DNS (IPv4)}.compute-1.amazonaws.com/my-app/{endpoint} (not working)
- {Public DNS (IPv4)}/my-app/{endpoint} (not working) (not working)
The security group of the instance is set like below:
Any help is appreciated
If your app is running on port 4000, you need to either open that port in your security group, or add a firewall/reverse proxy to forward from 80/443 to 4000.
You can use iptables to forward the port:
Forwarding traffic from 80 to 8080
or apache as a reverse proxy:
Apache redirect to another port

Deploying a Go app in AWS ec2 got connection refused

I have a compiled Go project that I want to deploy to an AWS EC2 instance. I just simply upload the application and run ./application on the remote server.
In the terminal, the application is running and says he's listening to localhost:3000.
I've already added the 3000 port to the security group.
However, when I tried to access it in my browser using <public-ip>:3000, it always shows connection refused, whether I've run the application or not.
I tried to run the app locally, it does work.
So is it because I deploy it incorrectly?
It is a bit difficult to help you because of no code being shared.
Some reasons why you got connection refused:
Your application is listening only localhost:3000
EC2 security group does not expose port 3000
How to fix:
Most applications are defining the host address on a config file or env variables. If you have access to change it, change it from localhost:3000 to 0.0.0.0:3000 to accepts connection from all IP or to your_ec2_public_ip:3000
If host address is hardcoded and you have access to code, change the code per above
If you don't have access to config or code to change the host address, then add a reverse proxy to route the incoming call to localhost:3000. This is a good link about using Nginx as reverse proxy https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/
Ensure EC2 Security Group allowing inbound connection for the designated port, in this case, is 3000 if you manage to route the incoming to your_ip:3000

Cannot list or download files from AWS EC2 FTP server from Heroku app

I have an AWS EC2 instance acting an FTP server as described here:
https://www.xadmin.net/how-to-setup-ftp-on-aws-ec2-instance/
The EC2 instance has a security group with custom TCP rules to allow connections from any IP.
Connections via FileZilla and other FTP clients are successful.
I have a Spring Boot app that connects to this EC2 FTP server and it works locally. However, when deployed to Heroku, attempts at listing files or getting specific files hangs without any error.
The Spring Boot app uses the full public URL to the EC2 instance as the FTP host (ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com).
How do I allow the Heroku app to access the EC2 FTP server?
Most probably the server is misconfigured and sends its internal IP address in the FTP PASV command response.
While FileZilla and many other FTP clients can workaround that, Heroku probably cannot.
Check FileZilla log file for:
Server sent passive reply with unroutable address in FileZilla.
If this is the case, you will need to fix your FTP server.

EC2 Multi App Instance - Some Ports not Reachable

I have started an AWS EC2 (UBUNTU 18 AMI) instance running three apps:
Web server on port 80
REST API on port 8786
DB on port X
I am able to
SSH into the instance
Reach the website via browser on port 80.
Reach the REST API from within the SSH session.
I am unable to
Reach the REST API via AJAX from the browser (tried postman as well).
I have
Configured the Security Group to receive inbound connections from all sources on 8786
verified that iptable is not loaded
Tried reaching the website from a mobile network - to no avail.
Swapped the ports between the Web Server and the REST API - which resulted in being able to access the API via the browser and postman.
Verified that the API is bound to 0.0.0.0 - not to localhost.
This smells like an EC2 issue, but I have no idea what to do.
Help would be much appreaciated.
As it turns out, 8786 is a reserved port, and should not be used. Issues were resolved when I changed to 8080, which I should have done in the very beginning.

Cannot access from browser on port 3000 even though added to incoming

I created an Ubuntu EC2 instance. I then am running a node.js express server on port 3000. Doing a curl to http://localhost:3000 gives me the HTML string I expect.
However when I try to access from the browser with the Public DNS (IPv4) which is ec2-18-221-209-77.us-east-2.compute.amazonaws.com. It is not loading. The browser spins forever at http://ec2-18-221-209-77.us-east-2.compute.amazonaws.com:3000.
I did put in my security group inbound rules, 3000 for Custom TCP and I set the source to anywhere. screenshot - https://i.imgur.com/2U24qUn.png
I also did netstat -tulnp and it seems :::3000 is open but only on tcp6, do I need it in TCP too? How can I do this? Screenshot - https://i.imgur.com/9jZVZH0.png