Not sure if you are still looking for a solution to this, but here goes. The Wordpress on Azure (container) app service is multi-tiered and has built-in proxy. The proxy config by default will add the headers needed to handle this scenario, as you can verify by looking at /etc/nginx/conf.d/spec-settings.conf
:
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
This however does not address the issue, but luckily, we also have Real IP module installed/running by default. With that in mind, all you need to do in order to resolve the issue is to add the following lines under the server
block in your /etc/nginx/conf.d/default.conf
file:
set_real_ip_from 169.254.129.0/24;
real_ip_header X-Forwarded-For;
where you might need to replace the CIDR range. Save the conf, reload nginx and you should be good to go:
And don't forget to update your startup script, as the changes will be overwritten after the container restarts.
P.S. Forgot to add the reference which helped me in troubleshooting this.