I have an app service using the azure provided WordPress image, which uses the wordpress-alpine-php docker image, running nginx version 1.20.2. I need to redirect HTTP to HTTPS, and www to non-www, with the Azure AppService version of WordPress. There isn't much documentation on this, and nothing I have tried has worked.
My issue is similar to the one described in this question, but the solution doesn't work. The file reference in that question, /etc/nginx/sites-available/default, does not exist. The sites-available folder does not exist, but there are files named default in these two locations:
/etc/nginx/conf.d/default.conf
./etc/nginx*/http.d*/default.conf
I have seen information saying I should add the server block to nginx.conf, but there are also two versions of this file, in the following locations:
- /etc/nginx/nginx.conf
- /home/site/wwwroot/nginx.conf
I've tried both of them, but neither seems to work. The one under etc doesn't seem to persist a container reload. I do know about copying the correct version and then reloading nginx with a startup command, as described in this Microsoft article. This doesn't work, but I may be copying over the wrong file.
After the copy, I restart Nginx with the command service nginx reload, but I get the following error.
The article above says to use this command service nginx restart, but it gives the error below:
How can I get the redirect to work?
Is there a better way to do this with the azure app service?