Is it possible in vscode liveshare to share port 443 (https)? - windows

I'm trying to share the port 443 from my development machine (win10) to my laptop (os x) using the amazing Live Share feature of Visual Studio Code.
On the dev machine I can access the service (running behind an nginx reverse proxy), so server is running fine.
VS Code doc mention a 1:1 mapping for the port "unless it's already in use".
Checking with sudo lsof -P -i TCP -s TCP:LISTEN on the mac, I can confirm 443 is not in use.
But the port on the mac is mapped to a random port (50150 in this case) instead of 443.
I guess I'm lacking some rights to open a sub 1000 port on os x.
Does anyone know what I can do (I mean other then running vscode as root)
Thanks

Short answer (for anyone who would find this later) : not possible!
Restricted ports are ... restricted.
And as I said in the question i don't want to run vscode as root.
But what I ok to run as root is a small utility to do port forwarding.
So I'm now using portforward (npm -> https://www.npmjs.com/package/portforward ) to do just that, and everything works fine.

Related

create react app On Your Network with WSL2 not working

I am trying to use a mobile device to view the app served by create react app. When I open the IP:PORT recommended by CRA's "On Your Network", the page never loads on my mobile device.
I am working on Windows 10 laptop, using WSL2 with Ubuntu. My network is all wifi, no ethernet cables. My code is on the Ubuntu file system and I run npm start from the same location in a WSL terminal from VS Code with the WSL extension.
I am able to see the app using http://localhost:3000 with browsers on my Windows machine (Chrome, Edge).
I noticed cmd.exe ipconfig lists the IP address that corresponds to "On Your Network" as "Ethernet adapter vEthernet (WSL)". This IP address (172.17.144.244) is different than what ipconfig shows as "Wireless LAN adapter Wi-Fi" (192.168.1.23). I also tried 192.168.1.23:3000 on my mobile device, but it didn't work either.
Some other posts on SO recommend removing a firewall setting that blocks NodeJS applications. I scrolled through the many applications listed in the firewall settings and found nothing for NodeJS apps.
Since WSL2 uses a virtual NIC what you need is enable port forwarding in the Firewall otherwise your server in WSL2 won't be seen by external PCs in your network.
I recommend reading the entire thread but in resume you can start using this script:
https://github.com/microsoft/WSL/issues/4150#issuecomment-504209723
I had the same issue. So instead of trying to restart the Windows, try to open the Powershell terminal, shut down the WSL, and then start it again. it solves to me.
Command to shut down: wsl --shutdown
Command to start: to start: wsl
Source: https://github.com/microsoft/WSL/issues/4885#issuecomment-803881561
I found a tool that fixes this problem: https://github.com/icflorescu/expose-wsl
First you need to run the command in the wsl terminal
npx expose-wsl#latest
and it gives you an ip address of your pc 192.168.0.130 for example, with that ip you can access the project from devices on the same network.
When running npm start:
.
.
.
On Your Network: http://172.48.228.88:3000
enter on mobile device:
http://192.168.0.130:3000
and works.
Note: You have to allow the port through the Windows firewall. In my case the firewall should allow access to 'C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.3.0_x64__...\wslhost.exe'
You can run your app in Docker instead and use Docker for Windows, enabled for WSL2. It somehow manages dynamic dynamically forward the ports, without having you to change anything in Windows.
I was also having the problem with hot reloading in WSL2 . I tried almost every solution present on github , stackoverflow and where not , from CHOKIDAR_USEPOLLING=true to setting FAST_REFRESH= false in .env file to changing network setting using netsh.... but none of them worked for me and after 2 days of searching solutions and trying to fix it .. finally reverted to wsl 1.
Just run this command on Powershell for now.
wsl --set-version Ubuntu-20.04 1
Consider Nginx for Windows.
I prefer this solution because I'm more familiar configuring web servers and reverse proxies than Windows networking and Powershell.
After unzipping the distribution, for example at C:\somepath\nginx-1.22.1, I add the following reverse proxy configuration to C:\somepath\nginx-1.22.1\conf\nginx.conf
...
http {
...
server {
listen 11500;
server_name wsl2_server;
charset utf-8;
location / {
proxy_pass http://localhost:11500/;
}
}
...
As you can see, I have a web server running on port 11500 in WSL2. When my mobile device requests "lan_ip_of_laptop:11500/", it then forwards to localhost:11500 and WSL2 server completes the request.

Not able to bind to docker container port

I manage to have Windows Server 2016 and Windows Container installed in my VirtualBox for testing.
I also follow the guide here https://github.com/Microsoft/Virtualization-Documentation/tree/master/windows-server-container-samples/iis-10.0 to build an image with iis installed.
However I'm not able to bind port 80 from container to any port in the host, here's how I run the container with port mapping and result of docker ps command:
I also try -p switch without explicitly telling the port mapping, but that doesn't work either
I tried to attach to the container and request the default iis web page using wget and everything seems fine:
And here's result of the docker inspect the container, in the exposedports section, it says port 80/tcp is exported, but not sure why it's not reflected in the host machine. Can someone give me an idea where I go wrong? Or is this a bug from Windows Container? I tried to post in msdn forum but their process of verifying account is really troublesome
https://api.myjson.com/bins/4a1f4

Why did the IP and port number change in Kitematic?

I am running Mac OS 10.10.3.
I am using Kitematic and Docker in a development environment. Yesterday I installed a container for Postgre. The mac ip and port for this container was 192.168.99.100:5432.
I shut down my system for the day.
Today, when I restarted my system, started Kitematic, and started the containner The ip and port was 192.168.99.100:32771.
Why did it change?
This is now supported. Click on Settings, then ports, click on the port and you can change it.
Issue on kitematic github.
I assume that you are not designating the port when you start your container and instead it is run with the -P option, which assigns a random port to any exposed ports. If you use the -p HOSTPORT:GUESTPORT option instead of -P the port will be consistent.
Check out the Expose and Run documentation
I think this feature has not been implemented yet.
https://github.com/kitematic/kitematic/issues/164
I don't believe kitematic supports assigning ports and only does the equivalent of the -P option of docker run.

Port 80 to 8080

First time I installed the package xampp I had many problems (like everyone who tries to use this programs and tries to create a website!)
I had made some researches on the web to find the solution to make Apache work: I setted the usual port 80 to 8080.
Now everytime I want to access to control panel of xampp or access to the DBMS MySQL I have always to add to the url ":8080" after "localhost".
My first question is: is it possible not to write ":8080" after the "localhost", maybe changing some settings I don't know where or in what file? (ex: "localhost:8080/xampp/" => "localhost/xampp")
Another thing: what could be the problems if apache is listening on the port 8080 instead of the usual one? (I don't have many experience in this field...)
Thank you in advance!
The only way to not write :8080 in the address bar is to make it work with the default port, which is :80. If the server does not want to start on that port it's probably because another program is already using it.
netstat -a -n -o | findstr ":80 "
With this command you can see which program is using your 80 port.

Can't access sinatra server from other computers

I am running a sinatra server with shotgun that returns a hello world when request GET in the root (typical tutorial) and works perfectly in my computer. I could only access it from localhost:9393 and then i run it with -o 0.0.0.0 and could access it as IP:9393 but still only from the computer where the server was running.
How can i access the server from other computers? already tried bind 0.0.0.0 and environment production.
Thanks in advance.
A bit more information is needed, like the OS that you are running and if you have made sure that any local firewalls are not blocking your traffic. I see that you marked this with the "Shotgun" tag which tells me that you are running on a *nix system as Shotgun uses forks and windows doesn't support them.
Check your iptables and see if you got anything in there. :)
iptables -nvL -t nat --line-numbers
iptables -nvL --line-numbers

Resources