Publishing Django project in EC2 AWS instance - django

I am trying to publish a Django Web page in an instance of AWS. I have configured the EC2 instance based on Windows machine, with elastic IP to get a fixed public IP. However, when I try to run the Django project, I can only assign the private IP. In this case, if, after running the project, I try to access the Web from the public IP, I cannot access the Web site (just an error message from the browser warning about the impossibility to access the site).
Below, the two snapshots of the execution. While the first one shows how with the private IP it works, the second one depicts the error I am receiving.
I have tried with the 0:8000, but also with <public_IP>:8000 without success. In the case of setting the public IP, I got Error: That IP address can't be assigned to. Last but not least, in the settings.py file, I have included ALLOWED_HOSTS = ['*'].
And, of course, during this test phase, I have allowed the traffic on the TCP ports within the security premises on the EC2 instance. Later on, I will remove some permissions, but I would prefer starting from the most open scenario.
Could you let me know how to proceed, please? Many thanks in advance.

Related

Incorrect public IP Address after upgrading AWS Lightsail (Plesk) snapshot to another Lightsail Plesk instance

I am trying to upgrade my hosting from the 1GB RAM to the 2GB RAM instance from an existing Plesk Lightsail snapshot to another Plesk instance. I was able to create a larger instance and load the snapshot successfully. I was able to access the files via FTP and the databases were all present as expected. However, when I logged into Plesk via {NewStaticIP}:8443/ (using the same credentials as I did with my old instance), I was able to login but the IP address shown was still the old one.
The mistake I made was that for my old instance, I had not assigned a static IP and was using the default public IP provided by Lightsail. If I had defined a static IP to the old one, it would have been easy. I would detach the static IP from the old and attach it to the new and there would be no need to make any change in the DNS records even.
However now, even if I change the A record to point to the new Static IP I've assigned to the new instance (I use Cloudflare), it propagates instantly but shows me a "Web server is down" (Cloudflare error 521). This is confusing me because the server has been set up and I can access it via FTP. Ports 80, 443, 8443, 8447, 21, 22 are all open as well.
When I try to access the website using the static IP, it shows an error that the server refused to connect.
In addition, via Plesk Tools, I was able to change the IP address shown for that server but I also read that it's not the best way to change the address of the server so not sure if this helps or not.
Any help regarding this would be much appreciated. Thank you...

AWS hosted website not working, what would be the problem?

please advise me.
I am no developer and very new to this. Our website is down and it keeps showing the following error:
This site can’t be reached
The connection was reset.
We are using AWS.
It keeps happening every few weeks. I tried redirecting it on AWS to a different website, for the time being, that didn't work either.
Any help is appreciated
If the website is hosted in EC2 instance
Check if your EC2 instance is having the same ip as earlier if it doesn't have a elastic ip associated with it chances are any restart of that ec2 instance might have changed the public ip address.
If above is same as earlier check the security group if it allows traffic on port 80 and 443 ( if using ssl )
And most importantly check if your website is indeed running i.e check with IP address in web browser i.e http://<ip_address>:<port>/ or https://<ip_address>:<port>/

How can I access my application from the public IP of AWS?

Whenever I tried to access to my deployed application on an EC2 instance of AWS using the public IP, I get the following messages on Chrome: "This site can’t be reached
ec2-54-194-153-202.eu-west-1.compute.amazonaws.com took too long to respond."
then, What changes shall I apply in order to grant access to the application properly ?,
Thank you,
The first thing to check in this case is The Security-Group inbound rules attached to your Ec2.
If your application is running behind a webserver like Nginx or Apache, check that your security_group is open in inbound for the public range (0.0.0.0/0) on the http port (80).
You can get this info on the Ec2 panel, click on your instance and check the attached security_group, click on it and check the inbound rules.
Here is a guide for you.
Notice : If nothing is running on your Ec2 it will never respond, be sure your app is served by a Nginx/Apache/Tomcat daemon.
Hope it helps !

Public IP on service for AWS in Kubernetes fails

I started a cluster in aws following the guides and then went about following the guestbook. The problem I have is accessing it externally. I set the PublicIP to the ec2 publicIP and then use the ip to access it in the browser with port 8000 as specified in the guide.
Nothing showed. To make sure it was actually the service that wasn't showing anything I then removed the service and set a host port to be 8000. When I went to the ec2 instance IP I could access it correctly. So it seems there is a problem with my setup or something. The one thing I can think of is, I am inside a VPC with an internet gateway. I didn't add any of my json files I used, because they are almost exactly the same as the guestbook example with a few changes to allow my ec2 PublicIP, and a few changes for the VPC.
On AWS you have to use your PRIVATE ip address with Kubernetes' services, since your instance is not aware of its public ip. The NAT-ing on amazon's side is done in such a way that your service will be accessible using this configuration.
Update: please note that the possibility to set the public IP of a service explicitly was removed in the v1 API, so this issue is not relevant anymore.
Please check the following documentation page for workarounds: https://kubernetes.io/docs/user-guide/services/

Unable to RDP to EC2 instance

I created a VM using Hyper-V on my local machine which I can RDP onto fine. I exported the VHDX to VHD and then uploaded it to AWS via the API.
This created a new EC2 instance for me but I cannot connect to it as it has no security keypair associated.
Thus I created a private AMI from the instance and re-instantiated a new EC2 instance from this AMI, setting the keypair in the process to ensure HTTP, RDP etc are permitted. The EC2 instance is running, but when I download teh RDP shortcut if fails to connect. I've tried rebooting the instance several times (as this was one of the suggested solutions on here when I searched) but it hasn't helped.
I also cannot ping any of these instances via the public DNS or private DNS.
Any idea what I'm doing wrong? I'm not even getting as far as the password prompt, its the connectivity is the problem.
Thanks
I had a similar problem - this is the tip from the AWS documentation that helped me solve it:
Verify that the route table for the subnet has a route that sends all traffic
destined outside the VPC (0.0.0.0/0) to the Internet gateway for the VPC
Additional debugging tips for this problem can be found here: Remote Desktop can't connect to the remote computer
The problem is probably the security group configuration attached to the instance. Make sure you have inbound TCP port 3389 permitted to be able to connect via RDP.
in username type:
.\Administrator
....and your decrypted password
See, this is local user. but you dont know real local hostname, that different from public DNS name.
Was helpful for me, hope for you too.
My guess for the reason you aren't getting anywhere has to do with the host certificates.
Be mindful that each computer connecting to the server via RDP needs to have an IAM user in AWS with an X.509 certificate uploaded to their account.
When importing or creating a windows AMI it is best to install and configure the EC2Config service.
The EC2 Config service does the following when you launch the instance:
At initial setup:
Sets the hostname to the private DNS name
Generates and sets a random password on the Administrator account
Initializes and formats the ephemeral disks
Generates and installs the host certificate used for Terminal
Services
Syncs the instance clock with a time server
After initial setup:
Writes the last three entries in the System event log to the Amazon
EC2 console so you can debug startup problems.
Prepares instances for bundling
Also, by default, security groups do not allow you to ping the instances. You must enable ICMP in the security group.
Hope that helps.
EDIT: Here is the link to the 64bit version of the EC2Config Installer
I also had the same problem. This is what I got from EC2.
Public DNS ec2-23-22-109-251.compute-1.amazonaws.com
User name Administrator
Password MyPassword
On the remote desktop, enter the domain and user name as
ec2-23-22-109-251\Administrator
If you paste the password is may not work, try to paste it but reenter the last 1 or 2 characters. Once you get the security certificate prompt accept/install it and your connection should open soon.
This is what worked for me:
Use your cell phone as a "hot spot" - which gives you a static IP address. That worked. Now, I'll need to contact my Internet provider to assign a static IP to my wireless router. Currently, it is spitting out DHCP IP addresses.
UPDATE:
12.7.2016
You need to go to the Security Group, select the Instance, then EDIT the RDP. If you click "MyIP" that should work for those of us working from home. If you are onsite, you may need to put in a custom CIDR.
After rebooting an EC2 instance, I found that I needed to reassociate the Elastic IP address associated with the instance. You click the button below then select the instance and private instance IP address when prompted.
RDP access worked after this step.
After patching Windows 2019 on my server, I couldn't access the instance anymore despite all my working settings didn't change. I used EC2Rescue to fix my issue
Please refer to the link below for details on how to use it: https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/troubleshoot-connect-windows-instance.html#AWSSupport-ExecuteEC2Rescue