Using Surge Module to Override Managed Configuration

Background⌗
I use Laravel Valet to set up my PHP development environment locally, and out of laziness, I changed the TLD (Top Level Domain) of my local development projects to .it
.
However, this domain conflicts with public domains, and if it goes through a proxy, it will request services on the public internet.
For related information, you can visit “ClashX Ignore Specific Domain Proxy”.
Solutions⌗
Change the local TLD to .local⌗
This solution is the quickest and most effective, but as a perfectionist, I didn’t want to do this.
Override the managed configuration file⌗
So I checked Surge’s official documentation and found that you can use includes to include configuration files, but it only supports the following configuration blocks:
[Proxy]
#!include Forwarding.dconf
[Proxy Group]
#!include Forwarding.dconf
[Rule]
#!include Forwarding.dconf
The configuration item we want to override is in the [General] block, so this method clearly doesn’t solve our problem. Then I came across the Module-related documentation.
I discovered that this feature can override existing configurations, which is exactly what I wanted. So I created a configuration file called SKIPROXY.sgmodule
in Surge’s configuration folder and wrote the following configuration information:
#!name=Skip Proxy
#!desc=Custom dns server and skip proxy config
#!system=mac
[General]
dns-server = 127.0.0.1, system, 117.50.10.10, 119.29.29.29, 223.6.6.6
skip-proxy = %APPEND% *.it
Module configuration supports overriding, appending, and inserting general configurations. For the dns-server option, I used override, while for the skip-proxy option, I used append.
After configuration, find the module configuration in Surge’s additional settings, and you’ll see an extra item with the name you gave your configuration file. Simply check to enable it and then click apply.
Then check if the Bypass proxy has been set in the system network configuration:
This way, you can use the local dnsmasq service to resolve domain names in your local development environment while ignoring proxy requests for *.it
hosts.
I hope this is helpful, Happy hacking…