We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

nginx + php-fpm + phalcon, phalcon routing problem

user nobody;

worker_processes 2;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log info;

pid logs/nginx.pid;

events { worker_connections 1024; multi_accept on; use epoll; }

http { include mime.types; default_type application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush      on;
#tcp_nodelay     on;

client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout  5;
send_timeout 10;

# HTTPS server
#
server {
    #listen       443 ssl spdy;
    #listen [::]:443 ssl spdy;
    listen       443 ssl;
    #listen [::]:443 ssl;
    server_name  localhost;

    access_log off;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_certificate      /etc/ssl/certs/bundle.crt;
    ssl_certificate_key  /etc/ssl/private/_tasteshop_co_kr.pem;

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

    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";

    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_trusted_certificate /etc/ssl/certs/AddTrustExternalCARoot.crt;
    resolver 8.8.8.8 8.8.4.4;

    location = /favicon.ico {
        log_not_found  off;
    }

    location ~ /\.ht  {
        deny all;
    }

    location / {
        root   /var/www/img;
    }

    location ^~ /upload {
        root  /var/www/img_server;

        #try_files $uri $uri/ @rewrite;

        rewrite ^/(.*)$ /index.php?_url=/$1 break;

        include        fastcgi.conf;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $request_filename;
        fastcgi_param  REQUEST_URI $uri?$args;
        include        fastcgi_params;

        gzip on;
        gzip_comp_level 2;
        gzip_proxied any;
        gzip_min_length  1000;
        gzip_disable     "MSIE [1-6]\."
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        client_max_body_size 10m;
    }
}

}


this is my nginx.conf(nginx + php-fpm + phalcon => for img server(static file(img file) with image uploading)).

but i got this errmsg 'That route was not found on the server.'

[folder structure]

/var/www/img => collection of img files

/var/www/img_server => phalcon upload module root (/var/www/img_server/index.php)

What's wrong?



58.3k

Hi man

You can refer my config for my app

server {
    listen      80;
    server_name phalcontip.com;
    rewrite     ^   https://$server_name$request_uri? permanent;
}
server {

    listen   443 ssl;
ssl    on;
ssl_certificate    /etc/nginx/ssl/csr/phalconjobs_com.crt;
ssl_certificate_key    /etc/nginx/ssl/private/phalconjobs.com.key;
ssl_session_timeout  5m;
ssl_session_cache    shared:SSL:10m;
ssl_ciphers  RC4:HIGH:!aNULL:!MD5:!kEDH;
ssl_prefer_server_ciphers   on;

    server_name phalconjobs.com www.phalconjobs.com;

    index index.php index.html index.htm;
    set $root_path '/usr/share/nginx/html/phalconjobs/public';
    root $root_path;

    try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }
    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;
    }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        root $root_path;
    }

    location ~ /\.ht {
        deny all;
    }
}

@Thien: Great job. This line did it for me! Thanks a lot.

rewrite ^/(.*)$ /index.php?_url=/$1


58.3k

You are wellcome

@Thien: Great job. This line did it for me! Thanks a lot.

rewrite ^/(.*)$ /index.php?_url=/$1