Stuck on Nginx index page - amazon-web-services

I have configured my subdomain on route53 to point to my ec2 public IP, right after I did this I got a welcome to nginx page. It was good this far. Now I add a custom cofig file in nginx/sites-available(also did link it to sites-enabled and also reloaded nginx). I don't see anything new. I still see the same welcome page. I wonder why this happened.I also have proxy_pass to :3000 which doesn't seem to work.
Here are the few things I tried and the result I got.
changed index.html file as mentioned in the root(/usr/share/nginx/html) - Still welcome page
tried server_name with both default_server and my subdomain(http://management.teampapercloud.in) - Still welcome page
stopped nginx service with service nginx stop - Surprisingly it still shows welcome page.
tried sudo lsof -i :80 (when nginx is running it has 2 diff nginx processed running one with root as user and the other www-data), when nginx is not running sudo lsof -i :80 gives nothing.
at this point i wondered if the domain hitting the server at all or not. I tried to ping, got my ec2 ip. tried DNS checker got my ec2 ip.
Now I am so frustrated stopped my ec2 instance. Now the welcome page is gone. which means I believe my ec2 instance is doing something to show the page, But I don't know which service.
checked top and service --status-all | grep + I don't see any strange services running nor services like Apache. as apache is not installed at all.
As a final try, I even uninstalled nginx. - I still see the same welcome page.
Updated all the index.html files I could find - Still same welcome page.
At this point, I am left with no ideas, and don't understand what is happening. Help is much appreciated.
Thanks

You have written, you reloaded nginx, try again (sometimes we forget to check common things):
sudo service nginx -t # check if configuration syntax is ok
sudo service nginx reload #reload configuration
sudo service nginx restart # restart server
Another important thing, check realtime log in terminal
error log: tail -f /var/log/nginx/error.log
access log: tail -f /var/log/nginx/access.log
and visit the page from browser and check the log in terminal.
Note: Log files can be in different directory in your server.
check log files with this: ls /var/log/nginx/
May be restart the os, if you have access to restart.
ec2 can have any page cache settings.
Are you using something cloudflare name server that can cache a
page, or, Any proxy server or something, that can cache the page.
You can even try browser incognito window, force reload in browser
(ctrl + shift + R).

The changes are not being applied because you're not making any changes to root directory which is
/var/www/html$
as this is a default public folder for your web server. Also if you wish you can change this default path to the one you want.
As you can see I have "index.nginx-debian.html" which on changing takes effect immediately.

Related

Plausible analytics on a server with a webapp

I have Django hosted with Nginx on DigitalOcean. Now I want to install Plausible Analytics. How do I do this? How do I change the Nginx config to get to the Plausible dashboard with mydomain/plausible for example?
Setup plausible by either running the software directly or in a docker container - let's say it runs on port 8080
Then in your nginx.conf - you should have a server block for your domain
Within that add a location block with the path you want plausible on and add a proxy pass directive to forward the requests to localhost:8080
Monitor access.log and error.log to debug any issues that may happen

AWS EC2 Instance Connection Refused in browser

I am somewhat new to this, so it's possible it's an obvious or dumb fix I have not thought of.
I have a EC2 instance I created with this AMI: ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20201026. I am using a 2020 Macbook Pro with Big Sur.
When I SSH into the server from my macbook's terminal, either via:
ssh -i FirstKeyPair.pem ubuntu#ec2-X-XX-XXX-XX.us-east-2.compute.amazonaws.com
or
ssh -i FirstKeyPair.pem ubuntu#X.XX.XXX.XX
I have no issues. To see if everything was working, I tried creating an index.html file in the root directory with nothing but hello world in it. I then ran PHP -s localhost:3000
However, when I try to navigate to my public IP X.XX.XXX.XX:3000, or `ec2-X-XX-XXX-XX.us-east-2.compute.amazonaws.com:3000 in my Chrome browser, I get "This site can’t be reached, X.XX.XXX.XX refused to connect, ERR_CONNECTION_REFUSED".
I have checked my Security Groups and opened everything, so they look like this.
And the same is happening on my outbound rules. I checked that I don't have a firewall on my mac as well. How can I get my PHP server, or just that index.html file, to show up when I navigate to my IP in the browser?
You're running your server on localhost which means that it is not accessible on the normal network interfaces. Try php -S 0.0.0.0:3000 instead. This says to listen on all interfaces. But be careful - this is not a recommended configuration and you should look into putting a real web server (i.e. Apache, nginx, etc.) in front of it.

Nginx Server stops automatically and my site goes down and i need to restart in a period of time

I have set up Nginx server on the digital ocean for my site, but Nginx stops automatically after 10-15 days and my site goes down and I need to restart it every time.
Can anybody tell me that why it is happening?
Thanks!
Have a look in the nginx error log usually located at /var/log/nginx/error.log
Also check that your server isn't being rebooted (due to system updates) and if this is the case ensure that Nginx is in the boot-up process:
chkconfig nginx on

Access Django App on AWS ec2 host

This issue might seem very trivial but please try to suggest a solution for this if possible.
I have deployed a django App on AWS ec2 host and I am able to run the following command successfully.
(venv)[ec2-user#ip-xxx-xx-xx-xx abc]$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
January 03, 2016 - 13:15:31
Django version 1.7.1, using settings 'abc.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
But I am not able to access http://127.0.0.1:8000/ from the browser.
On googling it's suggesting to use nginx or gunicorn. I am not sure if nginx, gunicorn etc. are to be used for this.
Can someone please let me know how can this be accessed from browser ?
Thanks,
You need to open HTTP port in AWS instance menu.(all ports except ssh closed in AWS)
Go to your console.aws.amazon.com, then pick your instance and go to last menu item "security groups". It lauch wizard, click on "Inbound" in bottom menu, then "edit", and add HTTP or any port what you want :)
And be sure you using your public AWS IP, to open in browser
Add some screen for you, hope it help:
In order to archive this all you need to do 3 simple steps.
Go to the EC2 Console and open up the security group of your instance. go to inbound tab.
click Edit and then press add rule...add entry with type of Custom TCP Rule and port 8000..
Go to your Django project,your app and open up the settings.py script. List your IPv4 address in the allowed_hosts section.. Ex : ALLOWED_HOSTS=['public IPv4']'
Now in the console run command python manage.py runserver 0.0.0.0:8000...
Open any web browser(from any device) and open the link 'public IPv4':8000
No need any app servers like Apache, NginX..
#Baterson is right. You should open port 8000 for your server first.
Official document is here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html . It is highly detailed.

Can't get server up and running digitalocean / django

I am very confused about how to set up my server because nothing seems to be working right. (I am a novice to all this)
I have the domain name dreamof.science with the registrar alp names. I have cloud hosting through digitalocean.
On digital ocean I have a droplet with nginx and django installed on my server through ssh on a secondary user (not root). There is an app I started from a book I am reading that teaches you django added onto it through my github in the directory sites/stratosphere.dreamof.science/source/django
I have been reading about this for days and the more I read the more I get confused. A records, AAA records, CNAMEs, PTR records, subdomains...I just want to know how the heck to get this server up and my app to run.
On my registrar I have my name servers pointed to the ones that digital ocean gave me for dreamof.science xx1.digitalocean.com xx2 etc.... On my registrar it also says I have 2 A records which all point to the same IP address which is the IP of my droplet. dreamof.science www.dreamof.science
I also have a CNAME to stratosphere.dreamof.science I am under the impression that this is my subdomain because you're not supposed to run apps on the regular domain....or something like that. Hence why I have my files in stratosphere.dreamof.science and nginx server config pointing towards stratosphere.dreamof.science
Now when I go to dreamof.science it just says "this webpage is unavailable." Same thing with stratosphere.dreamof.science and even when I just go directly to the server IP nothing shows up. I have the server running through the console on digital ocean and the droplet is active.
What is wrong here?
First, try creating a basic (empty) Django project in somewhere like /var/www/myproject. Start a debug server on port 8000 that accepts all connections using the runserver command like so:
python manage.py runserver 0.0.0.0:8000
Then navigate to http://dreamof.science:8000/ and see if you return a successful debug screen. That will tell you if the domain resolves correctly.
Now try setting a basic Nginx config, similar to the following:
server {
server_name dreamof.science;
listen 80;
location / {
proxy_pass http://localhost:8000;
}
}
Make sure that you don't have a firewall set to reject connections on that port.
Now try visiting http://dreamof.science/ to see if Nginx is running and set up to proxy the root domain to port 8000.