HTTPS connection rejected on Amazon ec2 instance - .htaccess

I have updated inbound rule to accept HTTPS, but when I hit from browser I get error err_connection_refused. I have run netstat -nupt -l but it does not show HTTPS opened. Is there any other way I can open https

You have to check two things to ensure that the HTTPS port are really opened in EC2.
Iptables. Ensure that the 443 port is opened to your desired IP
EC2 Security Groups. Go to the EC2 Managment console, go to "Network and Security" and find at witch security group is attached your machine. You can see the attached SG (security group in the instance properties). Probably it's not opened 443 port.

Related

AWS Application load balancer throwing 502

I am currently learning about AWS and I have a single EC2 instance running with a nodejs server on port 3000, an Application load balancer with SSL setup that listen on port 80 and 443 (http & https). When I make requests to the http route it returns back the successful health check message. But when I try to access my api via the https method, I get a 502 Error. I googled around and read some articles and they pointed out that the nodejs server keepAliveTimeout and headersTimeout should be higher than the timeout option of the ALB. I tried that and it didn't work. I also tried to set the max-http-header-value to 16384, I also tried to check the access logs for the load balancer on my S3 bucket and the logs just showed that I am getting a 502 error and nothing more. What could be the issue? Because I have tried all solutions that presented but they don't seem to work.
The 443 listener needs to be pointed to port 80 on the ec2 instance
The first thing to check is that your server is responding to requests. Try connecting to port 3000 on the server, either from the server itself (eg curl localhost:3000) or from outside the server (which will require the Security Group to permit access to port 3000).
Once you have confirm that the server is responding, configure Security Groups as:
A Security Group on the Application Load Balancer (ALB-SG) that permits Inbound access on ports 80 and 443
A Security Group on the Amazon EC2 instance (App-SG) that permits inbound access on port 3000 from ALB-SG
That is, App-SG should specifically refer to ALB-SG in its Inbound rules.
Then, configure the Load Balancer to have a Target Group that points at port 3000 on the app server and provide it a URL for the Health Check (that could simply be /).
Then, connect to the Application Load Balancer and see whether you can access your app.

Cannot access EC2 on specific port, even though I added security group

I created a web application and mounted it on an EC2 Windows instance.
Since it is created with Node.js Express and I didn't touch anything about localhost or port stuffs,
it is being listened on the port 3000 on npm start.
After I did npm start on the EC2 instance, then I can access it by "localhost:3000" within the EC2.
But when I try to access it from outside the EC2 with its public IP, like ip_address:3000, it keeps returning connection timed out error.
As I wrote in the title, I added a custom TCP security group that makes the instance opened for any IP addresses and with port 3000 but it still doesn't work.
What can I do? What am I possibly missing?
Thanks in advance.
Couple of things could be going wrong here.
Firstly - confirm your web application is actually running from within the instance.To do this on any recent windows in powershell: Invoke-WebRequest http://localhost:3000.
Secondly - confirm the security group on the instance allows incoming traffic for your designated port - HTTP(80) or HTTPS(443).
Thirdly - since you mentioned your instance has a Public IPv4 address, it must be located within a VPC and a Subnet. Navigate to the VPC service within the AWS Console and have a look at the Network ACL for that subnet. It's possibly denying all incoming traffic - rendering your security group settings unused.
If you're unsure on whether the subnet is blocking incoming traffic or not, have a look at these docs.

Why does AWS firewall not permit remote connection from my work computer?

I setup an EC2 instance (Amazon Linux AMI) to host a Docker API (Flask application with Python). The application is running on port 5000. Using my local PC (which is remote), I am able to hit the API with a browser (i.e., http://ipaddress:5000/), and get the "Hello, World!" response. The issue is that when I do the same thing on another computer (my work computer), I get a connection refused error.
In the security group for the instance, these are my inbound rule settings (I know this isn't secure, it's just a Hello World example):
HTTP (TCP): Port 80, allow 0.0.0.0/0, ::/0
SSH (TCP): Port 22, allow 0.0.0.0/0
Custom TCP Rule (TCP): Port 5000, 0.0.0.0/0, ::/0
The question: Why is the firewall blocking one remote computer and not the other?
The problem: Corporate firewalls will often set outbound rules that limit which ports you can access from websites outside of your organization.
The solution: Since Port 80 is a common port used for web servers, corporate firewalls (generally) don't block outbound traffic to these ports. Therefore, I was able to fix this problem by deploying the AWS API on Port 80. Then, I was able to connect to the API from within my corporate network.

Unable to establish connectivity on a port after configuring proper rules

I have a Linux VM on azure, which I can access using SSH without any issues. I needed access to another port(lets say 7077) from outside, and here is what i have done so far, but unable to establish connectivity
Created an inbound rule from the networking settings, it created the rule on the Network security Group attached to the network interface.
Added a new Network Security Group, attached it to the Subnet
If I do a netcat request on port 22, i get a successful connectivity, but for the port 7077 I get connection refused.
Also with IP flow verification passes for the port
Any pointer would be helpful.
You need to allow that same port in the firewall settings of the VM. The OS itself is what is refusing the connection suggesting you have not setup any firewall rules to allow that port.
Try adding a allow rule in the firewall settings and see if you can reach that port.
https://www.digitalocean.com/community/tutorials/how-to-list-and-delete-iptables-firewall-rules
http://www.thegeekstuff.com/2011/02/iptables-add-rule/
Ubuntu 17.04
https://help.ubuntu.com/lts/serverguide/firewall.html

how to configure security group in amazon EC2

I am new to this Aws security to deploy in amazon webservice.
When i restrict security groups with some IP address, my application runs dead slow or it may not run also, thats the reason i am getting connection time out when i try to call webservice which is deployed in aws. When i open the IP address restriction in Security groups it works fine.
How to configure my AWS using security groups. so that my application is accessible to only to some restricted networks.
Please help me put on this.
Below are the my security group details
INBOUND
Type Protocol Port range Source
MYSQL TCP 3306 X.X.X.X/X
SSH TCP 22 X.X.X.X/X
HTTP TCP 80 X.X.X.X/X
OUBOUND
Type Protocol Port range Source
MYSQL TCP 3306 0.0.0.0/0
SSH TCP 22 0.0.0.0/0
HTTP TCP 80 0.0.0.0/0
i am using hibernate for DB connection from my web application. But everytime i am getting connection timeout with the above security group. but if i remove the IP address restrictions it works fine.
Note: DB connection works fine from mysql workbench
<property name="hibernate.connection.url">jdbc:mysql://schemaname.amazonDBInsatnce:3306/test</property>
Security Groups will not "slow down" access to an Amazon EC2 instance. They are used to determine which ports are open to a given range of IP addresses. Either the traffic is allowed through, or it is not.
Security Groups can be defined for Inbound and Outbound traffic. By default, all Inbound traffic is denied and all Outbound traffic is permitted.
It is possible that your application is trying to access some external service and is timing-out, hence causing delays. Permitted all Outbound traffic is usually acceptable, so try that first and see if your application performs better.
Also, check the log files that your application is producing to see if any errors are being generated, which will give you a hint as to what might be happening.

Resources