Hosting site on different containers on same docker host - linux

I am trying to setup multiple containers listening on different ports hosting sites.
Example:
example1.com 8080 -> 80 container1 (apache)
example2.com 8081 -> 80 container2 (apache)
What is the correct way to do it?
I have tried http redirects/rewrites (inside containers) but cannot get it to work..

You need a reverse proxy on the server. I'd go with nginx and configure it similar to here to forward traffic to example1.com to its own port 8080. In Apache this can be done as well. It's called virtual hosts

Related

Nginx Proxy Manager (Docker) + mail server

im having a server running ubuntu with docker.
I have a docker instance running Nginx Proxy Manager to serve my multiple domains.
I want to run a mail server but since Nginx is using port 443 for HTTPS and 80 for HTTP i cant install any docker image's since they make use of both 80 and 443.
Example https://poste.io/doc/getting-started#download its also make use of the same ports.
Any idea how to have a single IP and host both web and mail?

Application stops after configuring nginx (docker) for https

I have followed this tutorial for deploying docker containers on AWS EC2 instance:
https://www.digitalocean.com/community/tutorials/how-to-secure-a-containerized-node-js-application-with-nginx-let-s-encrypt-and-docker-compose
and after reaching step 5 (where nginx is configured for HTTPS), the application just stops working. Here's my application: www.alphadevop.co
Here’s my nginx configuration:
https://github.com/cyrilcabo/alphadevelopment/blob/master/nginx-conf/nginx.conf
And here’s my docker-compose.yml:
https://github.com/cyrilcabo/alphadevelopment/blob/master/docker-compose.yml
[Here's the webserver logs][1]
[1]: https://i.stack.imgur.com/oawtD.png
Silly mistake, port 443 wasn't allowed on my application. I was confused because when i checked on my server, port 443 was open. Then I checked here, https://www.yougetsignal.com/tools/open-ports/ , saying it was closed. I then found out that there's an inbound rule for AWS EC2 instance top allow port 443.
Credits here: NGINX SSL Timeout

Configure subdomain port forwarding on EC2 VPC

I am running a Linux instance on EC2. It is running Apache on port 80 and a custom nodejs server on port 8080.
I would like to use a subdomain to redirect the petitions from port 80 to 8080.
Traffic to nodejs.mydomain.com:80 should be redirected to the EC2 server on port 8080.
Is that possible using AWS VPC?
I do not want to configure Apache as a proxy.
More details about the current configuration:
The instance has attached an Elastic IP address.
I'm using Route 53 to point my domain to this IP
The instance is running inside a VPC
The server is on production so I'm looking for a minimum downtime
Thanks for your help.

Hosting a MEAN app on Amazon EC2 - How to get domain name to link to my site?

Here's my situation: I followed this tutorial to host my website using Bitnami MEAN-Image on an Amazon EC2 instance - https://scotch.io/tutorials/deploying-a-mean-app-to-amazon-ec2-part-1. Then, I bought a domain name and set up my elastic IP address on my EC2 instance, and I've linked the domain and instance. If I run my app on port 3000 (npm start), I can see the app by going to mydomain.com:3000, but if I run my app on port 80, or if I don't run my app at all then I am taken to the default Bitnami MEAN page when I go to mydomain.com or mydomain.com:80. How do I get my app to appear on mydomain.com without specifying the port?
Editing to ask this; even without using my purchased domain name, is it possible to make my EC2 instance public dns default to my app's main page instead of defaultin to the Bitnami MEAN home-page?
If you have installed the Bitnami MEAN Stack, you will have your Apache server running on port 80, and it serves the default page located at /opt/bitnami/apache2/htdocs.
If you want Apache to serve your application by default, you can do it following the steps below:
Start your application in your port, for instance, the port 3000.
Go to your /opt/bitnami/apache2/conf/bitnami/bitnami.conf and add the following lines within your default Virtual Host configuration. It should look like this:
<VirtualHost default:80>
...
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
...
</VirtualHost>
Now, you should be able to access your application at http://your-ip/
You have to redirect your port 80 to 3000 so whenever they enter the domain or the ip, it gets to port 80.
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
use this and this should redirect the port 80 calls to 3000

Apache Port forwarding 80 to 8080 and accessing applications hosted both in Apache (80), i.e phpMyadmin and Tomcat (8080)

I want to access an application 'myapp' hosted in tomcat server(8080) currently can be accessed by http://example.com:8080/myapp in http://example.com/myapp (apache server, port 80). What should I do for that? If I use port forwarding 80 to 8080 will I be able to access phpMyadmin, or any other applications running in port 80? Which method I should follow to accomplish the task?
I am using Ubuntu server 14.04.
Use mod_proxy. Load module...
Second define in your virtual host:
ProxyPass /myapp http://example.com:8080/myapp
ProxyPassReverse /myapp http://example.com:8080/myapp
But this will work when your tomcat apps has only relative links.

Resources