You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Symfony 6.2项目部署至Azure Web App后出现403 Forbidden错误的配置问题求助

Symfony 6.2项目部署至Azure Web App后出现403 Forbidden错误的配置问题求助

大家好,我遇到了一个部署后的配置难题,想请教下各位开发者:

我用Symfony 6.2框架搭配PHP 8.2搭建了一个网站,通过GitHub Actions成功部署到了Microsoft Azure Web App上。但访问Azure生成的默认域名时,页面一直显示403 Forbidden, nginx/1.22.1错误。

我已经能通过SSH登录到这个Web App查看相关设置,确认我的Symfony项目是部署在/home/site/wwwroot目录下的。

下面是当前默认的/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;
#       }
#}

我很清楚需要按照Symfony官方文档里的Nginx配置要求来修改,但现在的问题是:每次部署都会自动覆盖nginx.conf文件,就算我手动修改了配置也没法持久生效,完全不知道该在哪里添加符合Symfony要求的自定义配置。

有没有大佬能给我指个方向?

备注:内容来源于stack exchange,提问作者Jasper Poppe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 12:35:29