0

I have problem with my configuration server on nginx.
My configuration:

server {
    listen                80;

    server_name           shop.md;
    index  index.php index.html index.htm;

    access_log            /var/log/nginx/test.dev.access.log;
    error_log             /var/log/nginx/test.dev.error.log;

    location / {
        root  /home/vagrant/Workspace/shop/web;
        try_files $uri $uri/ app_dev.php /app_dev.php$is_args$args;
    }

    location ~ .php$ {
        root  /home/vagrant/Workspace/shop/web;
        index  index.html index.htm index.php;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_param APPLICATION_ENV development;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
    }

    sendfile off;
}

This configuration allow urls like this :

http://shop.md:8000/1/femei-pantofi
http://shop.md:8000/1/femei-pantofi?min_price=1&max_price=1000

For this URL:

http://shop.md:8000

I get the error 403 Forbidden

1 Answer 1

1

I use the @rewriteapp directive of nginx for my Symfony2 projects. The resulting configuration looks somewhat like this:

# strip app.php/ prefix if it is present
rewrite ^/app\.php/?(.*)$ /$1 permanent;

location / {
    index app.php;
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    rewrite ^(.*)$ /app.php/$1 last;
}

# pass the PHP scripts to FastCGI server from upstream phpfcgi
location ~ ^/(app|app_dev|adminer)\.php(/|$) {
    fastcgi_pass phpfcgi-siyabonga;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param  HTTPS off;

    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
}

This works fairly well for me and is taken from the official nginx wiki page about Symfony2 with some additional changes. Also you should check the official Symfony2 docs. They have an example of a correct nginx configuration.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.