Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Charles Proxy - Map remote to localhost from https to http

I'm trying to use Charles to map requests for my server to localhost on my Mac. The server is on HTTPS and the local is HTTP. I'm trying that from the Chrome browser, iOS simulator and Postman. it always fails.

I set map remote in charles from my-server.com/* to http://localhost:PORT. If I try https://my-server.com/, charles maps the request but I get error in CONNECT request. If I try http://my-server.com, the request succeeds.

EDIT: There is an answer that suggests rewrite instead of map remote. it is good and working, but it feels to me as a workaround. I would like to use map remote as usual. I guess it require both Charles setup and machine setup

like image 249
gutte Avatar asked May 09 '18 08:05

gutte


Video Answer


3 Answers

You should try using the Rewrite function like this:

enter image description here

like image 82
kubano Avatar answered Oct 22 '22 15:10

kubano


enter image description here

As @kubano suggested, I'm using REWRITE tool with URL rewrite. In order to map all subpaths, I'm using regex group to replace the hostname but re-attach all that comes after '.com'. When wrapping something with () it is referred as 'group' and you can use it with $1 $2 ... and so on. in this case, what ever comes after '.com' is referred as $1 in the replace section

like image 32
gutte Avatar answered Oct 22 '22 15:10

gutte


I suggest using Map Remote from Proxyman to map between HTTP <-> HTTPS which is easier to setup.

Just create a rule, set HTTPS to HTTP, and the host. It will map from https://your-server.com to http://localhost:3000

Doc: https://docs.proxyman.io/advanced-features/map-remote

enter image description here

Disclaimer: I'm the creator of Proxyman and hopefully it would help you.

like image 2
Nghia Tran Avatar answered Oct 22 '22 14:10

Nghia Tran