mydomain.com:8080 routing - Amazon Web Services, Route 53, EC2, MEAN - amazon-web-services

I bought a domain name using amazon Route 53, created an elastic IP address and attached it to my Amazon EC2 instance running MEAN bitnami stack, then I created an S3 bucket for static web hosting "redirecting all requests" to the www.domainname.com.
However, when I go to my root domain the page loaded is the Bitnami Congratulations page: You are now running Bitnami MEAN 3.2.11-0 in the Cloud. I created a folder, uploaded my MEAN angular 2/express app and did node server.js and I can only access my web app on mydomain.com:8080 but anything else redirects to the Bitnami congratulations page. Which setting is it that is doing this? Is it an amazon setting? A Bitnami setting? or something in my server side code.
The only place I mention 8080 in my server code is here and it prints API running on 8080 when I run the server:
const port = process.env.PORT || '8080';
app.set('port', port);
const server = http.createServer(app);
server.listen(port, () => console.log(`API running on: ${port}` + ' or ' + process.env.PORT));

You have Apache running on your MEAN Stack. Apache is running on port 80/443 and, therefore, whenever you access your domain at port 80, Apache handle the request and shows you the "Bitnami Welcome Page".
In order to make your Angular/express application available at port 80 you need to configure Apache to redirect the requests to port 3000 (or port 8080, basically the port where your Express application is running). You could add under <VirtualHost _default_:80> and <VirtualHost _default_:443> sections in the file /opt/bitnami/apache2/conf/bitnami/bitnami.conf the line below:
ProxyPass /bitnami !
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
After that, you will need to restart Apache running:
sudo /opt/bitnami/ctlscript.sh restart apache
You can find more information at:
https://docs.bitnami.com/aws/infrastructure/mean/

Bitnami by default launches with an http config here: root/opt/apache2/conf/httpd.conf. The apache2 server pointed at a root directory containing html with an index.html that contains its Congratulations page. Using sudo /opt/bitnami/ctlscript.sh stop killed this server and all other services it had running by default on startup so when I type node server.js all traffic now goes to my Angular 2 app.

Use NGINX to reverse proxy all trafic from http://www.domainname.com to address where your node server is running ( http://localhost:8080).
Here is the sample NGINX configuration for such a use case.
To install NGINX follow one of tutorials on digitalocean.com depending upon your server OS.

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

Nginx Proxy Manager and django with nginx

I have a stack Django+Gunicorn+nginx running in docker containers. It is accessible from outside by domain and Port, like web.example.com:1300 . Also, there is Nginx Proxy Manager (NPM) running (uses ports 80 and 443) and succesfully managing some other resources (for example nextcloud). But it doesn't proxy to my django project at port 1300, shows "502 Bad Gateway".
In the Proxy Hosts of NPM I've added config:
domain names: web.example.com
Forward Hostname / IP: nginx_docker_container_name (this way it works with other resources)
Forward Port: 1300
Other settings: tried multiple combinations without success (like with and without SSL certificates etc.)
Is it possible to proxy using NPM?
Sorry if I missed to write some information, actually I do not know what else to state.
I managed to solve the problem myself.
So, nginx in docker container serves web-site with static pages. Nginx proxy manager proxying htpp protocol to nginx and secures communication (and also works from docker container in my set-up).
My mistake was that I didn't connect those docker containers by virtual network.
Ones I put them into one network - everything works.
Then I unpublished nginx port (1300).
NPM proxy settings are "standard", e.g. no "custom location" and nothing in "Advanced" tab. Just "Forward Hostname / IP" is docker container tag and "Forward Port" is nginx port it listens to (80 by default).
With WhiteNoise , you don't need to configure nginx for django static files
❤️❤️❤️

Access web server on VirtualBox/Vagrant machine from host browser?

I have a Django web server on a VirtualBox/Vagrant machine running Ubuntu.
I have followed this guide to create a Django project: https://docs.djangoproject.com/en/dev/intro/tutorial01/
I have a web server running at http://127.0.0.1:8000/ inside my guest machine. This is the first time I am running a Django web server. It is supposed to be a hello world app.
How can I access this web application from my host browser?
I have tried running ifconfig in the guest to get the IP that I should visit I found a promising IP address in inet addr.
But I have tried entering the following into my host browser and it didn't work.
http://inetaddrnumbers:8000/
How can I access the web server from my browser?
Try this.
Open the vagrant file (should be in the directory where you specified to create a new vagrant machine).
Search for config.vm.network. If you didn't setup the file earlier, it should be commented.
Change it to look something like this config.vm.network "private_network", ip: "55.55.55.5". Here ip address (55.55.55.5) can be any ip address you want.
Now logout from the vagrant machine and reload your vagrant machine by this command vagrant reload.
Again ssh to your vagrant machine and restart your django server by this command python manage.py runserver 0.0.0.0:80. Again the port address (80) can be 8000 if you want so.
After that, in your browser, enter the following address 55.55.55.5, and hopefully you should see your webapp.
Now if you would like to go further, you can edit your host file, and add this line
55.55.55.5 mynewdomain.com
Then in your browser, enter the follow address,
mynewdomain.com
And you should see your web app. Note that, www is not added in the domain name inside the host file, so only mynewdomain.com can be accessed. You can however add it.
Hope this helps. Cheers.
Complementing #Kakar answer, this configuration can also be done using this:
config.vm.network "private_network", type: "dhcp"
This will assign an IP automatically.
For further reading: https://www.vagrantup.com/docs/networking/private_network.html

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.

Configure Nginx To Accept Domain Name

I bought a Domain Name today, changed the DNS to match the exact VPS IP and configured Nginx to run my app.
So far, I can connect to my app using the external ip, from any computer, but I still can't connect to it via the Domain Name.
I've set the server_name to be the exact domain name I purchased, is there anything left I must do?
it is DNS configuration problem.
for sure about reason open putty and see output about site content by curl or wget or lynx.
example:
lynx mysite.com
if it work and returned proper result nginx config is true but it is DNS problem.
dns problems:
/etc/hosts
/etc/hostname
bad configuration
try ping sitename.com on your pc with ms dos. if has timeout then its not nginx problem.