I build a PHP website with Symfony framework version 6.2 and running on PHP 8.2.
Via Github actions, I managed to deploy it to a Microsoft Azure Web App.
When I visit the default domain, created by the Microsoft Azure Web App, I see a "403 Forbidden, nginx/1.22.1" error message.
Via SSH, I can go to the created Azure Web App to check some settings.
My Symfony website is deployed to the folder /home/site/wwwroot
.
This is the default /etc/nginx/nginx.conf
:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 10068;
multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log off;
error_log /dev/stderr;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
I’m pretty sure I need to change the nginx.conf
configuration like explained in the Symfony documentation:
https://symfony.com/doc/current/setup/web_server_configuration.html#nginx
But I have no clue where I can add this extra configuration, because the nginx.conf
file will be overwritten by every deploy.
Even when I manually change the configuration file, it doesn’t work.
Can someone point me into the right direction?
2
Answers
Thanks to @DragonBe, I found out that I had to change my nginx configuration in the file
/etc/nginx/sites-available/default
.I created a file
/home/site/wwwroot/nginx.default
in the root of my Symfony project:After the deploy with Github Actions, I run this command:
I hope this will help other Symfony websites with their deployment to an Azure Web App.
You’re thought process is correct, though you’re looking at the wrong configuration file. The file that should be modified is
/etc/nginx/sites-available/default
.For your second issue, where the settings are being overwritten, the solution is to use the command line instruction.
I have a full article about it on https://www.azurephp.dev/2021/09/php-8-on-azure-app-service/ if you want to learn more.
Good luck 🍀