This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
HaddockDev's profile picture

Ports in HTTP?

Started by HaddockDev, 26 November 2016 - 01:00 AM
HaddockDev #1
Posted 26 November 2016 - 02:00 AM
I am hosting multiple web servers on one of my VPS' because I have apache2 for my PHP scripts, and nginx for a Krist development server. Apache on port 80 and the Krist/nginx server on port 8080.
I need to access the Krist server with port 8080, but doing it the usual way (protocol://address:port) returns nil for a response.
(If your wondering why I'm using 2 web servers, I can't pipe Krist through apache2, but nginx supports upstreams and socket files, so Krist is running on that)

This is the code in question:
local resp = http.get("http://192.168.1.104:8080")
The resp variable is nil, when it should send a HTML page since I'm using no APIs.

How would I accomplish getting data from port 8080?
Edited on 26 November 2016 - 01:01 AM
EveryOS #2
Posted 26 November 2016 - 03:16 AM
Try routing it through a tcp webserver? With tcpsockets you can choose a port.
In ruby u can use these
Edited on 26 November 2016 - 02:18 AM
HaddockDev #3
Posted 26 November 2016 - 03:39 AM
Try routing it through a tcp webserver? With tcpsockets you can choose a port.
In ruby u can use these
FYI, I'm using Debian 8 as the OS, if that matters to you
Krist is written in Node.JS, and it uses nginx so it is accessible from a domain. I can't disable Apache, because the VPS is also a half NAS running Nextcloud that doesn't save settings, so if I take Apache down I have to reconfigure Nextcloud. So technically I can change the ports, but I can't because the version of Nextcloud I'm using likes to save it's settings in the server's memory. I also can't listen on the same ports with two programs.
TheRockettek #4
Posted 26 November 2016 - 07:34 AM
You could try ttying to request a get by using my "proxy" site

you get "http://therockettek.hol.es/get.php?url=" and it returns the content of the site. It could be used as a hacky way of getting ports as the server will handle the getting of the web address :3 Im gonna make it better and alsp make it support post soon :D/>
HaddockDev #5
Posted 26 November 2016 - 11:25 AM
You could try ttying to request a get by using my "proxy" site

you get "http://therockettek.hol.es/get.php?url=" and it returns the content of the site. It could be used as a hacky way of getting ports as the server will handle the getting of the web address :3 Im gonna make it better and alsp make it support post soon :D/>
It wouldn't work. My VPS is on my network, not exposed to the web. If it was a JS Script, it might of worked but (It needs to be clientside to work) it won't work with a local address.
Edited on 26 November 2016 - 10:26 AM
TheRockettek #6
Posted 26 November 2016 - 11:54 AM
You could try ttying to request a get by using my "proxy" site
you get "http://therockettek.hol.es/get.php?url=" and it returns the content of the site. It could be used as a hacky way of getting ports as the server will handle the getting of the web address :3 Im gonna make it better and alsp make it support post soon :D/>/>
It wouldn't work. My VPS is on my network, not exposed to the web. If it was a JS Script, it might of worked but (It needs to be clientside to work) it won't work with a local address.

erhm port forwarding…