remove port number from the url - url

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

Related

How can I access my local development server over the internet?

I have Wamp 3.1.7 running on a Windows 10 machine. The goal is to have the projects on this server accessible via the internet.
The server is available and working as expected over LAN when accessed with the LAN IP, e.g.
http://10.0.0.3/.
The server runs behind my router, which has its web interface running on port 80, so when I access my public IP, traffic on port 80 goes to the router login page.
Steps taken to try and solve the issue:
change the port my server is listening to from 80 to 8080. (this is working, both locally and over LAN, accessed with http://10.0.0.3:8080)
Add inbound rules on windows firewall for port 8080, set to allow all.
Add port forwarding on the router settings (forward incoming traffic on port 8080 to local IP 10.0.0.3:8080 as per https://portforward.com/d-link/dsl-g2562dg/)
Using PFPortChecker, it says that port 8080 on public_ip is open and able to send data.
I remain unable to access my server. When I go to public_ip:8080, I get ERR_CONNECTION_TIMED_OUT.
As stated above, going to public_ip just displays the router login page.
So as far as I can tell: port 8080 is open, my server is accessible over LAN on port 8080.
What am I missing? Where else could my traffic be blocked?
Stupid mistake on my side.
Answer found here: Public IP Web Page "Connection Timed Out" When Connected To
The issue was that you cannot access the server with the public_ip if connected the LAN the server is running on.

Docker container redirecting

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.

2 services on same hostname but different ports

I had 2 service on a server that run on 2 different ports. One of them on port 80 and another on port 3000. I want to address them like this:
http://xxx.ttt.example : the one that run on port 3000
http://xxx.ttt.example/zzz : the one that run on port 80
what should I do?
You need to use a reverse proxy server such as nginx to achieve this. As port can be mentioned only in SRV records at DNS level, and most browser ignore this record while resolving a dns query for a http request.
The domain will point to a reverse proxy server and at proxy server you can configure where to pull response from based on the request.
Setup -
Setup nginx reverse proxy server.
point your domain xxx.ttt.example to the nginx server.
In nginx config set a rule based on request uri fetch the response from port 3000.

Docker container published via port forward can't connect to its own published port

I have a docker container with an apache server on port 80. Port 8000 of the docker host is being forwarded to 80 in the container. Our application needs to connect to itself to use a web service. This connection URL is determined at runtime based on the URL the user is using to access the application. However, when it tries to connect to the host's IP address on port 8000, connection fails. Debugging with telnet and tracepath indicate routing error. Any hints?
The likely root cause here, is you're listening on the wrong interface in your container.
If you bind localhost:80 then you cannot access that using "publish". You need to bind 0.0.0.0:80 (or *:80 or whatever your config supports) and then it'll work.
Fixed. Turns out issue was that there was no firewall rule on the host allowing for access to the published port from the inside network.

How to change the default port of an EC2 instance

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.

Resources