Xampp, Apache and SSH tunneling - apache

I'm developing a PHP application on my localhost (Windows) using Xampp. I need to access a third party API from my application but I only have access to the API using our online server IP address.
How can I re-route my Apache requests to internet thru our online server using SSH tunnel?
(I can't setup a VPN connection)
Thanks

Assuming your the URL for your third party API is at:
192.168.200.100 on port 80
And your online server IP is:
10.10.10.100
To open the tunnel run the following command:
ssh -L127.0.0.1:8888:192.168.200.100:80 10.10.10.100
The ssh command will manually connect you to your online server and open an SSH tunnel that you can reference at:
127.0.0.1 on port 8888
So in your PHP application instead of connecting directly to the third party server at 192.168.200.100, you use your local IP and port (127.0.0.1:8888) instead.

Related

Tunnel intranet traffic to another external server for testing using SSH

I have two servers "Intranet" and "Internet" both running Linux.
A site is hosted on Intranet on port 8080. I would like to tunnel traffic from Intranet:8080 to the Internet:8008 server so that when someone attaches to Internet:8080 they access the web server on Intranet:8080
I cannot establish an SSH connection from Internet->Intranet as we are behind a firewall. But I could create a reverse tunnel from Intranet->Internet.
Is there a way to accomplish this with an SSH tunnel?

Reverse SSH tunneling with not localhost

I have local computer and remote server. Remote server is isolated and is only accessible with this computer. I want to connect to site from server, let it be https://example.com/site
I tried to make a tunnel via ssh -R 6761:example.com:80 remote-server. But when I am trying to use wget http://localhost:6761/site on the remote server - it doesn't work and show 404 whilst wget http://example.com/site working well on local computer.
What I am doing wrong?
You cannot tunnel HTTP that way.
The name of the server you are trying to reach will be included in the request (the Host header), but it will most likely only listen to example.com, not localhost.
You will need to set up a HTTP Proxy (Forward Proxy) on your local machine and tell your http client(s) to use that. (How depends on the client.)

Forward server HTTP traffic to handle in another device via SSH Tunnel

I'm developing some webhook required direct access public domain to internal machine, thinking use SSH tunnel to forward data, or got alternative solution?
Hosting server & development machine are in same network
192.168.1.2/24 (Hosting server)
2nd machine is virtual mapping using forticlient firewall without static or dynamic IP in visible in hosting server, so is 1 way initial communication right now.
In this case possible to setup SSH tunnel forward all traffic from 192.168.1.2:80 to handle in development machine port 8080?
How to ssh syntax look like?
Thanks.
This could be done by setting up an SSH tunnel to the remote machine:
ssh -L localhost:80:localhost:8080 development-system
Every request to port 80 on the hosting-server is now forwarded to port 8080 on the development-system.
Please note, that the port 80 on the hosting-server could only be used, when you start the SSH command as root. Also note that the port 80 is only accessible from the hosting-server. To access the port 80 on the hosting-server from everywhere use the following:
ssh -L 80:localhost:8080 development-system
Be sure that you want that.
A good introduction to the topic could be found at
https://www.ssh.com/ssh/tunneling/example
https://unix.stackexchange.com/questions/115897/whats-ssh-port-forwarding-and-whats-the-difference-between-ssh-local-and-remot

Connect to SSH (port 22) through tunnel opened in PuTTY on Windows

I want to connect to a remote server (host1) that accessible only from it's private network.
Another server (host2) is accessible from the Internet.
I opened a tunnel to host2 using PuTTY and tested it's working with Firefox (also checked that I got different IP address).
How can I connect to host1 using the tunnel I created?
I tried to configure proxy (to the tunnel I created - localhost) in PuTTY but it's not working.
The error I got: "Server unexpectedly closed network connection"
Pay attention that the host is the computer name in the network.
You connect to the local tunnel end directly, no "proxy" setting is needed.
This typically means that you use "localhost" as a Host Name. And a port according to your tunnel configuration.
See my guide for tunneling SFTP/SCP session. It's for WinSCP, but just use PuTTY instead of WinSCP in section Connecting through the tunnel.

IBM Server configuration

i have an ibm server, a tp-link router with an static ip and DHCP activated, i want to configure one of the net boards in the ibm server.
I installed Ububntu server and access to the net board configuration using this command:
vi /etc/network/interfaces
I configure the server with this
address -> i put an ip that i resrve in the router
netmask
network
broadcast
gateway
I have a subdomain from no ip i have entered in the server so i can do remote connection to the server throw this subdomain and ssh. I have put the subdomain in /etc/host.conf
The thing is i have access to the subdomain in the web and out of the LAN net. But when i try to connect to the server throw ssh it's gave me connection refused.
EDIT:
Using the command arp-scan -I eth0 -l i found that the IP of the server is asigned two times it's look like it's the same ethernet board with two MAC address thar are the same except the las number.
Ok, what's work for me was to reinstall openssh on the server and in my computer. After that I have access throw ssh.