When I try to open my instance via the Public DNS, I get a 404 error.
However, in my security group, I have HTTP/HTTPS/SSH configured to allow all incoming requests. When I connect to the instance via SSH, I can see all of my files there from my repo.
I am running on an Ubuntu 64-bit server with Nginx and Gunicorn.
Any help would be appreciated.
Thank you in advance!
Two possibilities for getting 404 file not found error
Make sure /usr/share/nginx/html/index.html is found or not.
check with nginx.conf file, if it is directing to index.html or not.
Related
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.
I have a google appengine project running in localhost. Everything works fine until i go to the 'login' page. When i go there i get the following error:
This site can’t provide a secure connection 127.0.0.1 sent an invalid response.
Try running Windows Network Diagnostics.
ERR_SSL_PROTOCOL_ERROR
the appengine command i use to run the project is dev_appserver.py" --host 127.0.0.1 . This is run pycharm. This only occurs in the 'login' endpoint and no other endpoint.
The console error i get is:
default: "GET /signin HTTP/1.1" 301 -
to connect over HTTPS you need a valid SSL certificate on your server here is you local server as I understand from the message. you can get a certificate for your local server but I don't think it's worth the trouble while working locally. On the other hand when you deploy to Google App Engine, you get SSL certificate automatically and it's managed by Google, that's why your code works without any problem in the deployment.
I just want to see my development working on an EC2, showing to some friends, and think in deploying it after all of the work is done, but react doesn't cooperate. :/
I did everything I always do.
Started a ubuntu server on EC2
applied a group with 3000/tcp opened in my instance
Installed all dependencies of my app, npm 11.1 and its packages via npm install.
npm started it
and...
Nope.. there is no "and"... just my tears over a bunch of attempts without reaching 3000/tcp via public ip and dns..
I even tested ping on it.. set ICMP echo request and response rules, tested and it worked, but when I try to reach the application by 3000/tcp port, nothing.
Does someone have any idea?
As an image talk more than a thousand words, there it is... My nighmare
PS: a curl on localhost:3000 inside the ec2 works just fine.. while
another curl outside the ec2 returns Connection Refused
Looks like the application is bound to localhost (127.0.0.1). Update your start property to include --host 0.0.0.0
Refer: https://github.com/webpack/webpack-dev-server/issues/147
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.
I'm trying to set up an SSH tunnel to access my server (currently an ubuntu 16.04 VM on Azure) to set up safe access to my django applications running on it.
I was able to imitate the production environment with Apache WSGI and it works pretty good but since I'm trying to develop the application I don't want to make it available to broader public right now - but to make it visible only for a bunch of people.
To the point: when I set up the ssh tunnel using putty on Windows 10 (8000 to localhost:8000) and I run http://localhost:8000/ I get the folowing error:
"Not Found HTTP Error 404. The requested resource is not found.".
How can I make it work? I run the server using manage.py runserver 0:8000.
I found somewhere that the error may be due to the fact that the application does not have access to ssh files, but I don't know whether that's the point here (or how to change it).
Regards,
Dominik
After hours of trying I was able to solve the problem.
First of all, I made sure putty connects to the server and creates the desired tunnel. To do that I right-clicked on the putty window (title bar) and clicked event log. I checked the log and found the following error:
Local port 8000 forwarding to localhost:8000 failed: Network error:
Permission denied
I was able to solve it by choosing other local port (9000 instead of 8000 in my instance).
Second of all, I edited the sshd_config file: sudo vi etc/ssh/sshd_config
and added these three lines:
AllowAgentForwarding yes
AllowTcpForwarding yes
GatewayPorts yes
I saved the file and restarted the ssh service:
sudo service ssh stop
sudo service ssh start
Now when I visit localhost:9000 everything works just fine.