403 Forbidden nginx/1.6.3 (centos 7)

Posted November 18, 2016 8.7k views

After i installed nginx/1.6.3 & php56w-fpm, i run my website in the browser with a VH listening for port 80 and it worked, but at the moment I wanted to create a VH that listens for port 443 to access via https and that’s when I get error 403 Forbidden, when I go to the error log what it shows me is *1 directory index of “/var/www/PROJECT/web/” is forbidden. I set 777 to www folder and i change the owner to nginx:nginx and the same error still comes out. The configuration of my VH is as follows

server {
listen 443 ssl spdy;
server_name project.lh;
root /var/www/PROJECT/web;

server_tokens off;

ssl on;
ssl_certificate /etc/nginx/ssl/cert.crt;
ssl_certificate_key  /etc/nginx/ssl/cert.key;

ssl_session_timeout  5m;
ssl_session_cache shared:SSL:20m;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers  HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers   on;

location / {
    try_files $uri $uri/ /app.php$is_args$args;
location ~ ^/app\.php(/|$) {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;

location  ~ /\.ht {
    deny  all;

location ~ \.php$ {
  return 404;

error_log /var/log/nginx/project-ssl_error.log;
access_log /var/log/nginx/project-ssl_access.log;


My site is made in symfony 2.8.
Could you please help me to explain how should i check? Thanks

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Add an index config inside the server {...} block preferably bellow root:

server {
    listen 443 ssl spdy;
    server_name project.lh;
    root /var/www/PROJECT/web;
    index index.php index.html index.htm;

Do a config test and reload Nginx:

sudo service nginx configtest && sudo service nginx reload
  • Thanks, already solve the error, now the error that is giving is “301 Moved Permanently” and redirecting to http, without any existing http configuration. I traced it with firebug and I get these two things

    URL State Domain Size Remote IP Time Line
    https://project.lh/ 301 Moved Permanently project.lh 376 B 87msl
    http://project.lh/ Aborted project.lh 0 B