I've got a Rails application running on port 3000 (or any port I want for that matter) and I can access it by browsing to the public ip like so: 1.2.3.4:3000 but I would like to reach the same page by simply omitting the port number, since my domain registrar only allows the public ip, and no port number. Is there a setting somewhere to direct all incoming traffic from the site to a specific port?
There are a number of ways to do this:
tell rails to use port 80 natively (see here)
use iptables to forward all port 80 traffic to 3000 (see here)
front your instances with ELB, and port map from 80 to 3000 (see here)
If the url is http and your rails app uses port 80, then you don't have to specify port in the url.
If your url is https and your rails app uses port 443, then you don't have to specify port in the url.
If it is not a problem to use any of these two ports, then you can try it.
Related
Hi i have a url called :
https://wona.logs.co.za
And i need it to redirect to the speciic docker container at port 3000
( http://156.43.123.226:3000)
However when i try link https://wona.logs.co.za to 156.43.123.226:3000 i cannot enter a port number in the redirection to specify my docker container
Multiple things that do not fit.
you try to redirect https traffic to an http endpoint. That won't wortk
you are trying to directly redirect to another port (from 443, to 3000). That won't work either.
Solution
Create a proxy container. e.g. nginx that serves port 80 / 443 and redirects traffic to your application on port 3000. I recommend that you do not directly expose your application - only via the proxy.
Once you have a proxy container that listens to the same ports you can easily use the redirect as you described.
The question lacks the current setup of docker on mentioned server. From what i understood, is you already have docker running with orchestrator and a proxy server for main domain, and now you want to put up a subdomain which forwards traffic to one specific container.
For this, you need to spin an image of your application which listens on port 3000, add an entry in proxy server to forward traffic to your new container. Handle the ssl handshaking at proxy level.
Is it possible to have a 2 docker containers serve on port 80 but different subdomains or hostnames?
Something like:
api.example.com goes to a node application
app.example.com goes to a Java application
Yes you can. using a proxy.
There is a project by jwilder/nginx-proxy which allows you to give your hostname via an enviroment variable which will than route your request to the appropriate container.
A good example of this implemented is given here: https://blog.florianlopes.io/host-multiple-websites-on-single-host-docker/
No. The first container you start will have exclusive access to the port, and if you try and start a second container on the same port it will fail.
Instead, use a load balancer such as Nginx or Traefik to handle the incoming traffic to port 80 and proxy it on to your two app containers based on host headers.
I've been doing some configuration, including releasing some ports, designating them to applications. I've seen so many applications want port 80. Can I ask what is so special with it? Why not port 90? 70?
Port 80 is the standard for HTTP which is the major networking protocol.
So if you have an URL like this (without any port number):
http://stackoverflow.com/questions/31242839/what-is-so-special-with-port-80/31242897#31242897
your browser will communicate with the webserver over port 80.
As #Glorfindel stated, port 80 is the standard for HTTP.
To elaborate - there are a number of fixed TCP, UDP ports "reserved" for different services from 1 - 1024. best practice is to use a port number larger than 1024 for non-standard traffic.
For instance, you might want both an IIS server and a tomcat server running on the same machine. you could issue 80 to one, and 8080 to another, or 8080 to one, and 8090 to another. (note that J2EE servers such as Tomcat, Glassfish, Weblogic, etc often default to 8080, which also defines as HTTP_alternate)
Also, in some operating systems, you need elevated privileges (administrator/root) to register a port below 1024, therefore you may want to use port 8080 in place of 80, for ease of use.
A further reading suggestion: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
Note also that (historically at least) Skype, for instance used port 80 to listen on, since it open in many routers, etc.
I'm running Rails con a VM with a bridged interface, it has it's own IP in the local network.
When I start rails in 0.0.0.0:3000 I can access it using the local network IP in the port 3000 without any problem.
The router NAT configuration is to route the port 3000 to the VM.
When I check the port 3000 on http://canyouseeme.org with the Rails server stopped it says the port is closed. With the rails server started it says the port is open. This means, the router is indeed routing to the VM, right?
But when I try to enter the server through my public IP in the port 3000, it won't answer.
I tried changing the server from Thin to Webrick, with the same result.
Also, I tried to run another web server in the port 3000 with he same results. No answer to public requests outside the local network. Yet the port is checked as opened.
Also, UFW is stopped, and anyway I allowed the port 3000.
Any ideas?
Some routers don't support loopback, meaning you can't access the public IP from within the LAN. FWIW, I tried this"
telnet canyouseeme.org 3000
Trying 8.23.224.110...
With no luck.
I have two instances of tomcat on a single machine both instances accepting secure request. Suppose:
one has connector port configured as 8080 and redirect port as 443. The other one has connector port configured as 8083 and redirect port 444. So if first tomcat receive request as
http://localhost:8080/abc/index.html
it then redirect to https://localhost/abc/index.html
and if 2nd tomcat receive request as
http://localhost:8083/abc/index.html
it then redirects to https://localhost:444/abc/index.html
now my problem is that i want to remove that port number 444 from the url. Is there any way to remove that or hide that. I can't use same port number 443 for both the instance.
thanks
No you can't do that. The web browser will only connect on port 443 for HTTPS if you don't specify a port.
Bind an additional static IP address to your computer and assign the second Tomcat to use 443 on that address. Add to your hosts file to use a non-numeric name.
192.168.1.99 localhost2