Persistent proxy settings

Started by topasio, January 22, 2021, 10:27:39 AM

Previous topic - Next topic
January 22, 2021, 10:27:39 AM Last Edit: January 22, 2021, 10:50:01 AM by topasio
Hello everyone,

I found many topics about configuring a proxy for OPNsense to access update server, suricata update etc.

- https://forum.opnsense.org/index.php?topic=3833.msg17998#msg17998
- https://forum.opnsense.org/index.php?topic=12098.msg55401

To set a proxy server I needed to configure this files:

/root/.cshrc


setenv HTTP_PROXY http://proxy:8080
setenv HTTPS_PROXY http://proxy:8080
setenv http_proxy http://proxy:8080
setenv https_proxy http://proxy:8080
setenv FTP_PROXY http://proxy:8080
setenv ftp_proxy http://proxy:8080


/usr/local/opnsense/service/conf/configd.conf


[environment]
## at the end of this section
HTTP_PROXY=http://proxy:8080
HTTPS_PROXY=http://proxy:8080
http_proxy=http://proxy:8080
https_proxy=http://proxy:8080
FTP_PROXY=http://proxy:8080
ftp_proxy=http://proxy:8080


/usr/local/etc/pkg.conf


pkg_env : {
    http_proxy: "{http://proxy:8080}"
    https_proxy: "{http://proxy:8080}"
}


This works like a charme and even after a reboot BUT after an update, the settings above are gone (only pkg.conf is not affected) ...

Is there any better or offical method, to use a proxy server?

Or is there a way to keep the settings persistent?

Cheers

Topasio

Update:

File /usr/local/etc/pkg.conf is not modified after update but /root/.cshrc and configd.conf are overwritten.

The only idea I have is to make this files immutable (chmod +i) but I guess this could probably create nasty sideeffects if the file should get an update ...

Any other ideas?

You could try setting the proxy settings in the GUI under System > Settings > Proxy. This should save the settings to the config files that you mentioned.

November 24, 2022, 02:25:31 PM #3 Last Edit: December 05, 2022, 04:43:27 AM by Galifatorss
Hello, I am glad you were able to find a way to configure the proxy server settings. I know that can be a difficult task. As for your question, I believe the best way to keep the settings persistent is to use the pkg.conf file. That is the only file that is not affected by updates. I hope this helps. Also, I use the proxies from https://shiftproxy.io. Due to their in-built software, I can set up my proxies easily, and the config will be automatically saved by the bot. It also might help you.