[Reserved] Linux using the ssl port forwarding

Original Address: Use ssl port forwarding on Linux  Author: Huyan ten

Background

As a back-end programmers, and others often have to FBI interface Every time, always the company's various, dev,qa,pre,prodand made environmental headache ,,, I really just want to see what the FBI simply can not be stressed through ah ... or when you're mobile terminal development interface, you want to complete experience play log this process from click APP to your computer (since the middle of several environment, you need to know is where is the problem), but found own office network has no independent ip .... then you can learn about the Linux port forwarding.

Local requests will be forwarded to the remote host port

This program is mainly used to solve the problem of access to the production environment. (Of course this is not good, but some important production environment, you can do this)

As a simple example, you execute locally:

ssh -L 4333:localhost:8000 root@xxxxx -N -f

To forward local port 4333 to remote port 8000, which means that you are a local call localhost:4333can be acquired to xxxxxthe server 8000results ports.

Now give a little complicated example:

For example, you now test code locally, we have become: localhost.

You want to connect to a production database, the local connection is not on the production database called:. Prod.

But you now have a dev machine, called dev.

On the dev machines can access the springboard to a machine, we call jump.

So how can run locally and connected to prod the database?

Require port forwarding on the dev machine.

Performed on the dev machine:

ssh -L 3333:prod:3306 root@jump -N -f

The result of the command is:

All Request dev machine 3333 port, will be forwarded for the jump on the machine prod:3306requests.

Now be executed directly in the local mysql -uroot -p -hdev -P3333you can connect to prodthe database, of course, user and password are required to be true online database of user and password.

Forwards the request to the remote host to the local port

This case is used to solve the problem within the network penetration, of course, you can also choose to set up ngrokservers, but trickier.

If you move and end py students and let them give you a package to test, to bind a test server, then the best course is to bind our local machine, so you can test anytime, anywhere. But we use every day wifi , ip address often become, how can this be done?

Casually looking for a server with a fixed ip, the best test is the company's server can unused port.

Then performed locally:

ssh -R 8092:localhost:6666 root@xxxxx -N -f

That will be xxxxxforwarding server access ports 8092 to 6666 on the local port, now you can let people request API's direct request xxxxxx:8092, and you can start the service on the local port of 6666, not only can be modified at any time of onset at any time, but also you can break point debugging.


Guess you like

Origin www.cnblogs.com/hanshuai/p/11101068.html