Localhost to local network port redirection on Windows - windows

I have a server that listen on http://localhost:8001 and I want to make it available in the local network. Unfortunately I don't have access to the code and can't modify the above. It doesn't listen to requests from outside the network on port 8001.
I want to make it both available in the local network and change the port to 9001. Is there some tool or way to use OS functionality to solve this?
It's a Windows computer and I don't have admin rights.
Edit:
I noticed both python -m SimpleHTTPServer and http-serv on node works if I use 0.0.0.0 as the address but I don't have the power to modify this program so I wanted some way to redirect the calls in a bidirectional way
Edit2:
It's a OWIN Selfhosted .NET Framework Application.

Simply using your hostname should be enough.
You only need a reverse proxy in order to change the port.
This is easy enough with a caddyfile:
caddy reverse-proxy --from :9001 --to 127.0.0.1:8001
And a caddy Windows release (like caddy_2.0.0_windows_amd64.zip) does not require any administration/elevated privilege: just use the caddy.exe. That is it. No setup, no installation, no registry modification.
Then:
https://<yourHostname>:9001

Related

Localhost refused to connect on WSL2 when accessed via https://localhost:8000/ but works when using internal WSL IP adress

What I'm Trying to Achieve
To access localhost from my local machine during the development of a Symfony web app.
My Environment
WSL2 running on Windows 10
Linux, Apache2, MySQL, PHP-7.4 stack (with Xdebug3 intalled)
Debian 10
Symfony 5.4 (although not sure on if relevant to this problem)
Steps I've Taken
Set up WSL2 according to this Microsoft WSL2 tutorial
Set up LAMP stack according to this Digital Ocean tutorial
Set up Symfony according to this Symfony tutorial
Run the following bash script on startup to start my services and set the host to the virtual WSL IP in my xdebug.ini file
#!/bin/sh
REMOTEIP=`cat /etc/resolv.conf | grep nameserver | sed 's/nameserver\s//'`
sed -i -E "s/client_host=[0-9\.]+/client_host=$REMOTEIP/g" /etc/php/7.4/mods-available/xdebug.ini
service php7.4-fpm start
service apache2 start
service mysql start
Run my Symfony project on the development server using symfony serve -d (Symfony then tells me "The Web server is using PHP FPM 7.4.23 https://127.0.0.1:8000")
Go to https://localhost:8000/ in Chrome where the app is running
What I Expect to Happen
My Symfony web app to be running on https://localhost:8000/ when I visit the URL in my Chrome browser
What Actually Happens
I get "This site can't be reached localhost refused to connect." in the Chrome browser
What I've Tried
This used to happen less frequently and I would give my laptop a restart, repeat the process above, and I could connect via https://localhost:8000/. However, it refuses to connect more regularly now (like 8/10 times I start up for the day)
Connecting to https://127.0.0.1:8000 yields the same result.
Connecting to the site using the internal WSL IP address, found using hostname -I and replacing localhost with this IP (still on port 8000). This is an adequate workaround to use my app, however I am unable to interact with my database via MySQL Workbench without having to set up a new connection, therefore a fix where I can use localhost would be very helpful!
(Based off comments) Only ran symfony serve -d without starting apache and PHP services separately - still sometimes allows connections to localhost but sometimes doesn't work.
Conclusion
The behaviour is odd as it works sometimes but other times it doesn't when the exact same steps are carried out. I am unsure where else to look for answers and I can't seem to find anything online with this same problem. Please let me know if any config files, etc would be helpful. Thank you so much for your help! :)
When it's working normally, as you are clearly aware, the "localhost forwarding" feature of WSL2 means that you can access services running inside WSL2 using the "localhost" address of the Windows host.
Sometimes, however, that feature breaks down. This is known to happen when you either:
Hibernate
Have the Windows "Fast Startup" feature enabled (and it is the default). Fast Startup is a pseudo-hibernation which triggers the same problem.
Typically the best solution is to disable Hibernation and Fast Startup. However, if you do need these features, you can reset the WSL localhost feature by:
Exiting any WSL instances
Issuing wsl --shutdown
Restarting your instance
It's my experience that localhost forwarding will work after that. However, if it doesn't, thanks to #lwohlhart in the comments for mentioning that another thing to try is disabling IPv6 on WSL2, since (I believe) there's a possibility that the application is listening on IPv6 while the Windows->WSL2 connection localhost connection is being attempted on IPv6.
You can disable IPv6 on WSL2 per this Github comment by creating or editing .wslconfig in your Windows user profile directory with the following:
[wsl2]
kernelCommandLine=ipv6.disable=1
A wsl --shutdown and restart will be necessary to complete the changes.
If you find that this works, it may be possible to solve the issue by making sure to either use the IPv4 (127.0.0.1) or IPv6 (::1) address specifically in place of localhost on the Windows side, or by configuring the service to listen on both addresses.
Try to run command netstat -nltp. It shows active addresses and ports. Your nginx process should be run at 0.0.0.0:8000. 0.0.0.0 means the nginx process is available from anywhere.
If your nginx process is ran by any specific ip address, you should access it by that ip address, e.g http://192.168.4.2:8000.

Is it possible to install localhost server in one pc and to access on multiple computers on a same network.?

We are building php web application while i am a designers and my friend is developer we work on different pcs we want to test the file by runnig on localhost on both of our pc how can we reach it. I have gone through some of concepts in internet but didn't get proper info.
Yes. You need to create a firewall rule to allow access through whatever port you are serving on, probably 8080.
Here is how to create an inbound port rule in windows
Then they should be able to access your server by simply using your ip

Cannot access macOS Server from the other mac using wifi

This is how it is managed in macOS Server:
and then from the other mac I do:
but it doesn't work, cannot login to remote mac. Why?
User kuna exists on mac with macOS Server and is an admin.
If you want to access your server from inside the office, don’t use the public IP - use the server’s local IP (one of the ones starting 192.168....)
If you want to access your server from outside the office, you may have to configure your office router to forward the relevant traffic to your server. This process is called port forwarding.
I’d
find out the port numbers you need to forward on this page
Google <name of your router> setup port forwarding for how to enter them into your router - although with many routers, the process is pretty self-explanatory in the admin interface.

Tunnel to heroku database?

I've got a django project on heroku and it uses postgre database on heroku (ec2). It all works fine, but on one computer I don't have access to postger port 5432 so I need to setup a tunnel from my computer to there. Is that possible?
You will need to have some sort of access to an intermediate host to make it possible. Heroku does not support it out of the box.
Corkscrew does SSH over HTTP proxy. Then you can open a transparent proxy like tsocks. This way you don't necessarily have to know about the firewall.
This all applies to Linux and possibly Mac. On Windows you can pipe your connection through Putty.

is it possible to install a simple proxy webserver on a VPS to bypass a blocked port?

My webhosting company serves up Control Panel on a funky port number (20000 or something). This port is blocked from work, so I cannot access Control Panel during the day (in case of emergency).
Is it possible, and is there an easy way to run a simple proxy on a VPS so I can browse to the VPS on port 80 and have it talk to the Control Panel machine on the funky port 20000?
Any suggestions are helpful!
Thanks,
Rob
Just start a SSH-forward:
ssh -L 8080:localhost:20000 user#yourhost
You can access your config interface using http://localhost:8080
You can create such a tunnel using Putty on Windows, too. http://oldsite.precedence.co.uk/nc/putty.html

Resources