mailinabox
mailinabox copied to clipboard
Dynamic DNS: Allow overriding http method in request parameter
I own a DSL router that allows me to specify a custom url for dynamic DNS updates, but which can only do GET requests.
In order to be able to update addresses on a mailinabox server, I added the option to emulate the required request method bu specifying it in a request parameter.
I’ve been meaning to tackle this for a while. I’ll review and test this later. Of course it’s up to @joshdata to determine if it’s merged.
Would it be a better option to have a dedicated endpoint for this, something like "@app.route('/dns/dynamicdns/
Additionally I would imagine nginx could rewrite the GET to PUT via a specific URL without needing to modify daemon.py
I can confirm that this works when added to /etc/nginx/conf.d/local.conf below "location /admin/ {..." to allow any request to be rewritten to PUT when proxied to the maib daemon.
location /dynamicdns/ {
proxy_method PUT;
proxy_pass http://127.0.0.1:10222/;
proxy_set_header X-Forwarded-For $remote_addr;
add_header X-Frame-Options "DENY";
add_header X-Content-Type-Options nosniff;
add_header Content-Security-Policy "frame-ancestors 'none';";
}
both of these commands were successful using GET when PUT should have been used with /admin: curl -X GET --user ...:... https://m.domain.com/dynamicdns/dns/custom/testdns.example.net curl -X GET --user ...:... https://m.domain.com/dynamicdns/dns/custom/testdns.example.net/A -d "1.2.3.4"
It may be a better idea still to have a new endpoint in the daemon just for this purpose.