Ok, I'll try answering you.
Consider Apache HTTPD and Apache Tomcat two friends (I'll call them in short HTTPD and Tomcat).
Each of them has means of comunicating with other people, let's say by mobile phone and lineland phone or IM.
Tomcat has three phones for recieving calls:
One for recieving international calls in which he speaks the langauage spoken by most people in the (informatic) world, HTTP. This phone has an international agreed subnumber (port) which is 80, but can be any number. It happens that Tomcat being a bit eccentric preferes 8080 by default, so you can speak him HTTP at port 8080 by default.
Another phone for recieving calls from international VIP people, which want to be ultra sure they are speaking with Tomcat and nobody can listen their call, so they speak the previous international language but switching words (encryption, HTTPS). By international agreements this port is 443, but as we said Tomcat is eccentric, he chooses for this port 8443.
The third Tomcat's phone he uses it to recieve calls only from people that speak his own language, AJP (He lives in Java Application Server Country). By International Common Law, it's port 8009.
HTTPD has only two phones for recieving calls
- The first two are the same as for Tomcat but HTTPD is not that eccentric prefering to use the normal agreed numbers, 80 for HTTP and 443 for HTTPS.
The story
Now HTTPD has a shop. Sometimes costumers ask for stuff not present in the shop but when he knows Tomcat has it he calls Tomcat and asks him to bring the things.For speaking with Tomcat HTTPD can use international languages, HTTP and HTTPS, but often Tomcat is more happy to speak his own language, AJP. So HTTPD knows that there are two translators that can help him speak AJP with Tomcat, mod_jk (http://tomcat.apache.org/connectors-doc/) and mod_proxy_ajp (https://httpd.apache.org/docs/2.4/mod/mod_proxy_ajp.html).
Now being more serious, by default, HTTPD listens on ports 80 for HTTP and port 443 for HTTPS.
Tomcat listens on port 8080 for HTTP, port 8443 for https and port 8009 for AJP.
You can configure the ports for HTTPS using Listen directives in it's configuration file, httpd.conf or files included from it. So grep for Listen to check them.
You can configure Tomcat for the ports in server.xml. In Tomcat language those are connectors (as opposed to Listen in HTTPD). And as for your configuration, if you setup Tomcat to use HTTPS he will redirect requests in HTTP to the port configured.
Keep in mind, HTTPD keeps care of his ports, Tomcat of his own ports and a port can be in listen only from a single application at a time. So if you have both HTTPD and Tomcat in the same machine, they fit nicely, as the ports used are different by default:
HTTPD: Ports 80 and 443
Tomcat: Ports 8080 8443 and 8009.
Unless I am misunderstanding, why not simply map different target ports on the Linux Server to port 80 on the backend devices. For example:
Netbook --> 192.168.1.1:8080 (Linux Server) --> 192.168.0.2:80 (NAS)
Netbook --> 192.168.1.1:8081 (Linux Server) --> 192.168.0.1:80 (Router)
You already have the commands you need, you just need to set --dport
to a different target port on the Linux Server, while specifying port 80 in --to-destination
.
Best Answer
What you really need here is a reverse proxy (such as Nginx) that can do SSL termination for you on port 443 and then pass the request to Tomcat on port 8443.
SSL/TLS is complex, and in my view, relying on IPTABLES to handle the SSL handshake and get your request to the Tomcat application is not a good idea.
If you really need to use IPTABLES, connect to the service with
openssl
and find out exactly what is happening. Report output here and more help might be available.The issue may also be that you're using the
nat
table. My understanding is that rules for this table are only applied if the requests are being routed through the server, as opposed to be routed to a different port on the same ip address.A reverse proxy would remove a lot of this complexity, and give you lots more functionality (eg rate limiting, access control etc etc) to boot.