@Mark Irvine Hello! To update the nginx configuration for your WordPress site running on Azure App Service, you can follow these steps:
- SSH into your App Service instance using the Azure Cloud Shell or any other SSH client.
- Navigate to the
/home
directory and create a backup of the default nginx configuration file by running the following command:
sudo cp /etc/nginx/nginx.conf /home/nginx.conf.default
- Open the nginx configuration file in a text editor by running the following command:
sudo nano /etc/nginx/nginx.conf
- Add the following code block to the
http
section of the configuration file:
# BEGIN SMUSH-WEBP
location ~* "wp-content\/(uploads\/)(.*\.(?:png|jpe?g))" {
add_header Vary Accept;
set $image_path $2;
if (-f "/var/www/wordpress/wp-content/smush-webp/disable_smush_webp") {
break;
}
if ($http_accept !~* "webp") {
break;
}
expires max;
try_files /wp-content/smush-webp/$image_path.webp $uri =404;
}
# END SMUSH-WEBP
- Save the changes to the configuration file and exit the text editor.
- Test the configuration file for syntax errors by running the following command:
sudo nginx -t
If there are no syntax errors, you should see the following message:
nginx: configuration file /etc/nginx/nginx.conf test is successful
- Restart the nginx service by running the following command:
sudo service nginx restart
If you see an error message about the port being in use, it's possible that another web server is running on the same port. You can check which process is using port 80 by running the following command:
sudo lsof -i :80
This will show you the process ID (PID) of the process using port 80. You can then use the following command to stop the process:
sudo kill <PID>
- Replace
<PID>
with the actual process ID.