If you like DNray Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

DNS-based solution for redirecting domain ports

Started by Pournima, Jun 07, 2023, 06:44 AM

Previous topic - Next topic

PournimaTopic starter

Hello, my apologies for the awkward phrasing of the question. Let me provide some context.

A certain software connects to a server using a domain and port 8888. Within the same software, its update system refers to the same domain but with port 80. Unfortunately, it's not possible to change the software itself.

The server in question is located on a network where access to port 80 is closed (while port 8888 is open and functional). Also, changing the network settings isn't an option.

Here's the question: How can I redirect "domain:80" to one server and "domain:8888" to another with minimal expenses?

As of now, the only solution I see is setting up an A-record on the DNS server to direct requests to a new server with open ports. Then, filter said requests through iptables and redirect them to different IP addresses (using thread hosting for 80 and an existing server for 8888). However, this solution requires about 2-3k rubles per server since most VDS don't have the necessary iptables modules.

Do you have any recommendations? Perhaps there's another way to achieve this?
  •  


rickys

Do you mean to say that iptables are not present on your primary server? Which operating system do you use?
Can't you install it from the repositories too?
  •  

ElitemotCeame

Perhaps something along the lines of:

The following commands are an example of how to use iptables to redirect incoming traffic from port 80 to port 8888:
iptables -I INPUT -p tcp --dport 8888 -j ACCEPT
iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-port 8888

However, if changing the recipient is indeed impossible, perhaps it could be worth exploring the possibility of redirecting packets to the source instead. This may require additional configuration and testing, but could potentially provide a solution.
  •  

fallfro

Assuming that the server is not receiving packets on its tcp:80 port due to a router blockage, the most viable solution would be the one that you have presented.

It is worth noting that such issues can be resolved easily on any virtual dedicated server (VDS) starting from as low as 190 rubles per month, which also offers unlimited traffic and haproxy.

Ultimately, it is important to ensure that proper network configuration is in place to avoid potential disruptions to the server's functioning.
  •  

jackgrylls

In this scenario, we can implement a reverse proxy server, such as NGINX or Apache, to handle the traffic redirection. Here's a step-by-step breakdown of how to accomplish this:

1. Set Up a Reverse Proxy Server: Deploy a new server that will act as the reverse proxy. This server will listen on port 80 for incoming requests.

2. Configure the Reverse Proxy Software: Install and configure NGINX or Apache to act as a reverse proxy. These widely used web servers have robust proxying capabilities, making them an ideal choice for this task.

3. Define Proxy Rules: Create rules within the reverse proxy server's configuration to handle incoming requests and route them to the appropriate destination based on the requested domain and port number.

  - For requests to "domain:80," configure the proxy to forward these requests to the new server where the traffic should be directed.

  - For requests to "domain:8888," set up the proxy to route these requests to the existing server that interacts on port 8888.

4. Handle Proxy Traffic: Configure the reverse proxy server to handle the incoming traffic efficiently, managing connections, load balancing if necessary, and maintaining secure communication between clients and the destination servers.

5. SSL Termination (Optional): If SSL termination is required, the reverse proxy can handle incoming HTTPS requests on port 443 and then proxy the traffic to the appropriate backend servers using plain HTTP or a different SSL configuration.

6. Testing and Monitoring: Thoroughly test the setup to ensure that traffic is correctly routed based on the defined rules. Additionally, implement monitoring to track the performance and health of the reverse proxy server and the backend servers.

By implementing this solution, you can effectively redirect traffic from "domain:80" to one server and "domain:8888" to another server without the need to modify the original software or the network settings. Additionally, utilizing a reverse proxy approach provides flexibility, scalability, and the ability to manage traffic redirection in a centralized and efficient manner. This solution allows for the seamless transition of traffic to different destinations based on the port number, meeting the requirements of the original scenario.
  •  

ataek

One cost-effective solution could be to set up a reverse proxy on a server that has access to both ports. Using Nginx or Apache, you can configure the server to listen on port 80 and forward requests to the appropriate internal service based on the port. This way, you won't need to change the DNS A-records, and it circumvents the port access issue. Just ensure the server has the necessary modules enabled.
  •  


If you like DNray forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...