Question

how to forward my vps1 to my vps2 script

hi. i have installed a ssh panel on my vps , but bcuz my country keep filtering th ips , i need to forward my iran vps to my digital ocean vps . my ssh panel using apache and the panel will open with this link :

t2.domain.com/p

but i wanna open the panel with :

t1.domain.com/p

t1 is the domain of my iran vps , so what i need is when someone enter t1.domain.com/p iran server forward this request to digital server and open t2.domain.com/p

i did forward my ssh port with socat so my clients can connect to digital ssh throw my iran vps server easily but bcuz this panel doesn’t have any port on the domain i don’t know how to forward it .


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
May 27, 2024

Heya,

To set up the forwarding of your SSH panel from your Iran VPS to your DigitalOcean VPS using a web URL, you can use a reverse proxy setup. Since you mentioned your SSH panel is running with Apache, you can configure Apache on your Iran VPS to act as a reverse proxy that forwards requests from t1.domain.com/p to t2.domain.com/p.

Here’s a step-by-step guide on how to do this:

Step 1: Enable Proxy Modules

First, you need to ensure that the necessary proxy modules are enabled in Apache on your Iran VPS. You can do this by running the following commands:

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests
sudo systemctl restart apache2

Step 2: Configure Your Virtual Host

Next, you’ll need to create or edit a virtual host file for t1.domain.com. Here’s how you can set it up:

  1. Open the virtual host file for editing. If you don’t already have a specific file for t1.domain.com, you can create one:
sudo nano /etc/apache2/sites-available/t1.domain.com.conf
<VirtualHost *:80>
    ServerName t1.domain.com

    ProxyRequests Off
    ProxyPreserveHost On

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass "/p" "http://t2.domain.com/p"
    ProxyPassReverse "/p" "http://t2.domain.com/p"

    ErrorLog ${APACHE_LOG_DIR}/t1.domain.com_error.log
    CustomLog ${APACHE_LOG_DIR}/t1.domain.com_access.log combined
</VirtualHost>

This configuration tells Apache to forward any requests for t1.domain.com/p to t2.domain.com/p, while also handling the response headers so that the client’s browser behaves as if it were communicating directly with the origin server.

  1. Enable the new virtual host:
sudo a2ensite t1.domain.com.conf
  1. Reload Apache to apply the changes:
sudo systemctl reload apache2

Step 3: DNS and Firewall Configuration

  • Ensure that the DNS settings for t1.domain.com are correctly pointing to your Iran VPS.
  • Check if your firewall settings on both the Iran and DigitalOcean VPS allow HTTP traffic on port 80 (or HTTPS on port 443 if you are using SSL).

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel