How would I bind a port to a secondary public ip while keeping the same primary ip? - port

Basically im trying to run 2 websites on both my ip's but I cant figure out how to bind a port to it. Im running ubuntu 20.04. The secondary IP is one I got from my VPS provider.
I havent ever used 2 ip's before so any help would be appreciated :)
I have tried using sudo ip addr add xxx.xxx.xxx.xxx/24 dev eth0 and it does add it to the interface but when I actually bind a port to it, its not reachable from outside connections
I dont know if its because I havent got any private ip's/subnet's assigned. Im a complete noob in this field xD

Related

Nginx proxy manager is not being able to serve the page from another docker container

I am trying for nginx proxy manager (running in a docker container) to connect to another docker container that has port 8080 open on it. When I setup the proxy to connect to 192.168.0.29:8080 the ip address of the host, but it doesn't work, the browser just says that the site didn't send any data.
I tried setting up the reverse proxy with other services (that weren't running inside a docker container), and they worked flawlessly. So, I've concluded, the problem is something with the docker containers.
First, I tried replacing the ip address with the address of the container (shown in portainer) which showed to be 172.17.0.2. But, that didn't work. I can confirm that both containers are in the same network, bridge.
I could not find any solutions for this problem either here, at Stack Overflow, or anywhere else. Hope there's enough data to solve this problem. Thanks ahead of time!
Edit:
running arp -na from within the container gives this output:
[root#docker-00244f7ab2cc:/app]# arp -na
? (172.17.0.1) at 02:42:d1:fc:fc:6b [ether] on eth0
I found the solution to my question after lots of searching and testing and it's quite simple. The solution is to start the nginx proxy manager docker container on the host network instead of the bridge network. Then, you can use localhost and then the port to refer to which service you want to redirect to.

Link docker container to external public IP

On performing curl ifconfig.me on my machine I am able to get my public IP but the same does not works in my container.
The simple answer to my silly question is, we don't need to. Instead port binding is use to bind the container port to the system.
The public IP of system could be used with port to interact with hosted application.
Silly me!

Access Docker Container Name By DNS Subdomain

Basically, I have Docker Swarm running on physical machine with public IPv4 address and registered domain, say example.com
Now, I would like to access the running containers from Internet using their names as a subdomain.
For instance, lets say there is a mysql container running with name mysqldb. I would like to be able to access it from Internet by the following DNS:
mysqldb.example.com
Is there any way to achieve this?
I've finally found a so-called solution.
In general it's not possible :)
However, some known ports can be forwarded to a container by using HTTP reverse-proxies such as Nginx, haproxy etc.

How to hit the api that runs on ubuntu inside virtualbox?

i'm facing difficulties to hit the api runs on ubuntu inside virtualbox. virtualbox's ip address is 10.0.2.15 . when im trying to hit this ip, i cant access it.
so help me to hit the rails api, that runs on port 3000
TIA
Probably your Linux firewall is blocking connection.
So you can do two things make changes in IPtables rule to allow connection
OR
Just turn IPtables service off

How to configure docker containers so that I can access them outside the host

I know many would say that this is a redundant question. But I am putting this thread as my last straw. I have gone through many threads in this community regarding my query, but was not able to achieve what I need.
Here's what I need to do.
Make docker containers such that it's IP would come in the same network as my host's. Just like a virtual machine in bridged network.
I need to be able to ssh to these dockers via external machines in my host m/c's network.
I simple replace Virtual Machines with docker in my system. And for that I need to ssh them just like I have been doing with the Virtual Machine nodes.
What I have tried?
Able to ssh the container via my host m/c. Where I installed ssh on container and enabled the port 22. Also I set UsePAM to no in /etc/ssh/sshd_config file.
Followed Ben Whaley on this thread.
I tried IP aliasing, But after all that, when I did ssh <IP address> -p 5000 , I got ssh: connect to host <IP address> port 5000: Connection refused error.
Tried to follow Regan on this page. But those documents were pulled down, and The documents that I found was not helpful either, as they were proving hard for me to understand.
Tried to make a bridge from this reference. But there too, my virtual0 bridge was not taking any IP address. If I manually give one to it, it wasn't accepting any connection through that IP.
Please can anyone help me out here?
I just need to replace my VM's with the docker containers so that I can improve my resource utilization.

Resources