HTTP/HTTPS Proxy Recorder in conjunction with PHP Server

How can I configure my PHP Server I installed locally on my Windows computer to allow running PHP projects on the same port where proxy is listening?

Problem:
The HTTP Proxy Gatling Recording seems to work as expected if you start it when port 8000 is free:

However I can not serve my PHP project on localhost:8000 when the HTTP Proxy Gatling Recorder is running/listening on this port.

When I try it the other way arround: I serve my PHP project with succes first on port 8000 and then I try to start the Gatling recorder on port 8000, I receive the following error:

I have no idea how I can use my PHP application in conjunction with the Gatling proxy recorder. I was unable to find resources online for this specific problem in conjunction with Gatling. For now, it seems like HAR will do the job, but I’m curious IF it can work with the Proxy Recorder and so HOW??

I’m also unable to post more than 1 picture demonstrating my problem, since I’m a new user.

That doesn’t make any sense. You can’t have a proxy listen on the same port as your target on the same host.

You should use distinct ports for your proxy and your application.

Okay, I can now see traffic from other sites like nu.nl for example when I use port 8000 for my Gatling recorder and localhost:3000 for my PHP project.

Still, the proxy recorder doesn’t pick up executed events from localhost:3000.

I’m assuming the proxy recorder is meant to track traffic to other remote machines and not an application on your own machine (localhost)?

Hi @fons-000,

This is a common limitation in recent browsers. For instance, see the “Connections to localhost […] are never proxied” mention in the Firefox settings:


(Source: Connection settings in Firefox - Mozilla support)

You may tried to deploy your application in another location (remote server), or maybe override this protection in your developer settings of your browser.

Cheers!

Regarding FireFox, it’s possible to re-enable proxies on localhost with the network.proxy.allow_hijacking_localhost config option, see Proxying localhost on FireFox

Alright, I tried the Gatling HTTP proxy approach for Firefox using port 8080. I can sucesfully browse everything on the internet and see it in my Gatling HTTP proxy recorder in executed events.

However still after setting the network.proxy.allow_hijacking_localhost to true, I now get a white screen of death (WSoD) when trying to view my localhost:3000 application.

Aren’t there more people that had a similar problem unable to view a served (PHP) application with the HTTP Gatling Proxy?

I think it’s best I just use the HAR Converter for now, that works perfectly.

For people that may read this in the future.

It seems like if you want to use HTTP/HTTPS proxy in your PHP application run on your localhost, you need to configure your PHP application to use the proxy by setting the proxy configuration in your PHP code or through environment variables. If you run another type of localhost app, consider checking out how you could configure your application to use the proxy. Check out: https://www.youtube.com/watch?v=9F5ll-qS76I&list=PLhW3qG5bs-L-YQKiESvWmzIlS-dMo1b4D&index=4

I personally haven’t done this, since the HAR converter is an easy option for recording traffic both localhost and remote apps. The HTTP Gatling proxy seems to work easily for non-localhost apps!

Cheers!