Easy server proxy?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Caronte3D
Addict
Addict
Posts: 1371
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Easy server proxy?

Post by Caronte3D »

First of all, I don't have much experience with servers of any type :?

What I need is:
Run a server (on a vps), access it from the client web browser, where the client ask for something like: https://myserver.com/test/img.jpg, then the proxy modify that url to: https://anotherserver.com/test/img.jpg?key=APIKEY, and server the result to the client.

What would be the easiest way to do it?

I don't know if PB is enough or I need more... standard tools?
Last edited by Caronte3D on Fri Feb 21, 2025 10:58 am, edited 1 time in total.
User avatar
JHPJHP
Addict
Addict
Posts: 2267
Joined: Sat Oct 09, 2010 3:47 am

Re: Easy reverse proxy?

Post by JHPJHP »

[REMOVED]: Non PB answer, misunderstood the requirements.
Last edited by JHPJHP on Thu Feb 20, 2025 5:17 pm, edited 1 time in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
Caronte3D
Addict
Addict
Posts: 1371
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Easy reverse proxy?

Post by Caronte3D »

Hey! JHPJHP :wink:
Thanks! I will wait for more options, but the php seems a good option.
About the .htaccess, I don't know, but... maybe the redirection exposes te apikey on the client browser url bar? :?
User avatar
JHPJHP
Addict
Addict
Posts: 2267
Joined: Sat Oct 09, 2010 3:47 am

Re: Easy reverse proxy?

Post by JHPJHP »

Hi Caronte3D,

Your original question included a QUERY_STRING for the API Key.
It didn't make much sense at the time, but I guess it could have been an enclosed environment.

Would probably be helpful to others if you provide additional details:
• What format is the is the image expected, or is just the image name required as your previous post suggests?
• Otherwise, the server is probably expecting either the full URL to the image or the image converted into Base64.
• Redirecting from a server you control, then a POST request using the Fetch API is an obvious choice.
• Most (API) servers have specific requirements (i.e. expecting JSON).
• I'm assuming you'll be receiving a response, what's the format of the response?

I probably have tunnel-vision; wait for a PB answer:
As I just finished an App that served both an image URL and Base64 image string to a server that required an API Key.
• The API Key was secured, the POST data was JSON encoded, and the response imaged data was also JSON encoded.

Anyways, good luck.
Last edited by JHPJHP on Thu Feb 20, 2025 5:11 pm, edited 2 times in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
Caronte3D
Addict
Addict
Posts: 1371
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Easy reverse proxy?

Post by Caronte3D »

My example was only a general one (not mine), but if you ask me for more specific...:
For my current project, I need to consume tile maps of this site: https://protomaps.com/api so... the only thing I want to hide, is the apikey for obvious reasons.
In resumen, The apikey must be only in my server where no one can see it.
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Easy reverse proxy?

Post by idle »

atomic webserver does tls terminating reverse proxy on windows but only with pb 6.12
so you can run multiple domains on the same machine or other machines behind the nat.
It doesn't work properly on linux though which might have been an issue with the tls lib version or build

but you can easily fetch recourses with atomic webserver too with https requests
User avatar
Caronte3D
Addict
Addict
Posts: 1371
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Easy reverse proxy?

Post by Caronte3D »

idle wrote: Thu Feb 20, 2025 9:29 pm but you can easily fetch recourses with atomic webserver too with https requests
I don't mind if the server needs Windows for this, in fact my first choice was AtomicServer, but I haven't enough skills to do what I need transparently.
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Easy server proxy?

Post by idle »

It easy enough to fetch a resource but it also depends on whether you need to parse the return from the api
I sent you an example
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Easy server proxy?

Post by idle »

I've got it working in atomicwebserver but I can handle it better by changing how URI handlers are implemented
so you can set them by depth so domain/tiles/ will catch any children under it like domain/tiles/z/x/y
it makes more sense plus it's easy to cache them to disk to reduce the overhead of fetching them again.
User avatar
Caronte3D
Addict
Addict
Posts: 1371
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Easy server proxy?

Post by Caronte3D »

Image
Post Reply