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

 

How do I get information from a machine located behind gray ip address?

Started by mr2299muslim, Feb 26, 2023, 02:03 AM

Previous topic - Next topic

mr2299muslimTopic starter

There is a target computer, named target.host, running Apache. The target has a dynamic IP address, making it inaccessible from outside connections. A server, linked to example.com and utilizing a static IP address, is present. A user desires to access the target's website.

Is there a pre-existing solution to create a tunnel that forwards requests from the server to the target computer while providing CC responses to the user? Ideally, the user could log in to test.example.com and view contents from test.target.host.

Alternatively, can this only be accomplished through custom programming? If so, the user would need additional software installed on their device, potentially in the form of a separate program or browser plugin.
  •  


keith.bowman

The command "ssh -CND user@remote.host -R 80:127.0.0.1:apache_port" might not function properly since it occupies port 80, which is already in use by Apache. Instead, it is recommended to use a different port (e.g. 8791) and set up a virtual host on the server for test.example.com, directing it with ProxyPass at 127.0.0.1:8791/.

It should be noted that using port 80 and the user "user" is not feasible due to the former being privileged and inaccessible to the user.

The -CND options are necessary for traffic compression and shell avoidance, respectively. For dynamic port forwarding in the opposite direction, the -D option is required to create a local socks via the remote server. Finally, all keys, including -R, must be written before the host name being connected to, although ssh may ignore this.
  •  

outsourcefirm

It is unnecessary to write custom code for this process. Instead, configure password-free ssh authorization with target.host and input the command "ssh -CND user@remote.host -R 80:127.0.0.1:apache_port".

Afterwards, remote.host can be accessed on port 80 as if Apache is running on that machine and not target.host. In case of a broken ssh connection, autossh utility can be utilized to restore it.

The -CND options are utilized for traffic compression and shell avoidance while using ssh.
  •  

cabsco

Utilizing DNS can simplify the process. Firstly, enable the dyndns service on a host with a gray IP. Secondly, create a record under the domain zone example.com as follows: test.example.com CNAME my.dyndns.host.
  •  

maabuft

The solution involves using a reverse proxy, such as Nginx or Apache with the mod_proxy module, on the server linked to example.com. The reverse proxy will act as an intermediary, forwarding requests from the user to the target computer while hiding the dynamic IP address of the target.

Here's how it can be set up:

1. Configure the Reverse Proxy on the Server (example.com):

   a. Set up a Virtual Host or Server Block for test.example.com:
      - Create a new virtual host or server block configuration file for the test.example.com domain.
      - In the configuration file, specify the server name, document root, and other relevant settings.

   b. Configure the Reverse Proxy:
      - Install and configure the reverse proxy software, such as Nginx or Apache with the mod_proxy module.
      - In the virtual host or server block configuration, add the necessary directives to forward requests from test.example.com to the target computer (target.host).
      - Example Nginx configuration:
        ```
        server {
            listen 80;
            server_name test.example.com;

            location / {
                proxy_pass http://target.host;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
            }
        }
        ```
      - The proxy_pass directive forwards the requests to the target.host, while the other directives ensure that the necessary headers are forwarded to the target computer.

   c. Secure the Connection with SSL/TLS:
      - Configure SSL/TLS encryption for the test.example.com domain.
      - This can be done using a trusted SSL/TLS certificate, either self-signed or obtained from a Certificate Authority (CA).
      - Update the virtual host or server block configuration to redirect all HTTP traffic to HTTPS.

   d. Establish a Secure Connection to the Target Computer:
      - Ensure that the reverse proxy can securely connect to the target computer (target.host).
      - This can be done using techniques like SSH tunneling or a VPN connection.
      - Configure the reverse proxy to use the secure connection when forwarding requests to the target computer.

2. Configure the Target Computer (target.host):

   a. Ensure Apache Web Server is Running and Accessible:
      - Make sure the Apache web server is running and accessible from the reverse proxy.
      - Verify that the target computer's firewall is configured to allow incoming connections from the reverse proxy's IP address.

   b. Allow Remote Connections (if necessary):
      - If the Apache server is not already configured to allow remote connections, update the configuration to permit access from the reverse proxy's IP address.
      - This may involve modifying the Apache configuration file to include the necessary directives.

3. Provide the User with the test.example.com URL:

   a. Inform the User:
      - Provide the user with the test.example.com URL to access the target computer's website.

   b. Seamless User Experience:
      - When the user visits test.example.com in their web browser, the reverse proxy will transparently forward the requests to the target computer (target.host).
      - The user will see the content as if they were directly accessing the target.host website, without any additional software or plugins required on their device.

This  setup ensures that the user can securely access the target computer's website through the test.example.com domain, without needing to know the dynamic IP address of the target computer. The reverse proxy handles the necessary routing and secure connection, providing a seamless experience for the user.
  •  

thebangaloredhaba

Quote from: mr2299muslim on Feb 26, 2023, 02:03 AMThere is a target computer, named target.host, running Apache. The target has a dynamic IP address, making it inaccessible from outside connections. A server, linked to example.com and utilizing a static IP address, is present. A user desires to access the target's website.

Is there a pre-existing solution to create a tunnel that forwards requests from the server to the target computer while providing CC responses to the user? Ideally, the user could log in to test.example.com and view contents from test.target.host.

Alternatively, can this only be accomplished through custom programming? If so, the user would need additional software installed on their device, potentially in the form of a separate program or browser plugin.
Yes, you can create a tunnel using tools like SSH or a reverse proxy to forward requests from the server to the target computer. This allows users to access it through a static URL like test.example.com. This can often be achieved with existing solutions without custom programming. However, if specific features are required custom development may be necessary. Users might need to install additional software or a browser plugin depending on the chosen method.
  •  


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