0

Recently, I moved an EE site from Apache server to Nginx server. But there seems some issues while accessing any other page/link rather than HOME. Its showing only home page. I know that Nginx server does allow htaccess rules so I tested by with index.php on the same but no luck.

PS: EE Control Panel working perfect and I am using NSM Config Bootstrap

Could anyone please help if have faced such an issue? I 'll highly appreciate your help.

Thanks,

3
  • Nginx is not using .htaccess.
    – Max Lazar
    Feb 7 '14 at 10:35
  • 1
    @Bhashkar, my edition on Max's answer maybe help you.
    – Sobral
    Feb 7 '14 at 14:40
  • @RobsonSobral thanks a lot ... i am looking further into it... Feb 7 '14 at 14:50
4

What configuration you use? what rules you setup in your nginx configs? For example, I use next configuration for Nginx+PHP-FPM:

server
{
    server_name www.example.com;
    return      301 $scheme://$host$request_uri;
}

server {
    listen 80;
    server_name example.com;

    #access_log  /dev/null;
    #error_log /dev/null;

    access_log /home/www/example.com/log/example.com-access.log;
    error_log  /home/www/example.com/log/example.com-error.log info;

    if ( $http_user_agent ~* (nmap|nikto|wikto|sf|sqlmap|bsqlbf|w3af|acunetix|havij|appscan) ) {
        return 403;
    }

    root /home/www/example.com/public/;

    client_max_body_size       20m;
    client_body_buffer_size    128k;
    client_body_temp_path      /var/nginx/client_body_temp;

    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
        access_log        off;
        log_not_found     off;
        expires           360d;
    }

    location ~ /\. {
        access_log off;
        log_not_found off;
        deny all;
    }

    location / {
        # the index directive checks first for "index.html" because
        # sometimes you need to rename "offline.html" to "index.html"
        # to take the site down during an update
        # if you can, move this to the HTTP level;
        index index.html index.php;

        # accept URI without index.php
        try_files $uri $uri/ /index.php;

        # Remove index.php
        rewrite    ^/index\.php(.*)    $1    permanent;
    }

    # insensitive case on extension of PHP files
    location ~* \.php$ {
        # Zero-day exploit defense.
        # http://forum.nginx.org/read.php?2,88845,page=3
        # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your fingers that you won't get hacked.
        try_files $uri =404;

        expires off;
        fastcgi_pass unix:/dev/shm/php-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param MAGE_RUN_CODE default;
        fastcgi_param MAGE_RUN_TYPE store;
        include fastcgi_params;
    }
}
7
  • Hi, Max. Actually you don't need that conditional for the existence of the file. Do you mind I improve your answer? I don't see the need to answer again, because my answer is almost the same.
    – Sobral
    Feb 7 '14 at 11:33
  • sure, I will glad to see. something like * location / { index index.php; try_files $uri $uri/ @ee; } location @ee { rewrite ^(.*) /index.php?$1 last; } * ?
    – Max Lazar
    Feb 7 '14 at 11:36
  • Almost. I see a lot of people around recommending unnecessary NGINX rules for EECMS. You code is one of the best I saw. Let's improve it a little.
    – Sobral
    Feb 7 '14 at 11:57
  • Hi Max, thanks for your input. I 'll ask to server administrator to update the configuration for the same. But I am still not sure about the problem of showing home page while accessing any template or entry page. Is it related to configuration? This problem arised when we moved the site on server running on Nginx. Feb 7 '14 at 15:07
  • @Bhashkar Yadav, probably your configuration isn't passing the $uri to PHP-FPM. I've seen EECMS running so good on NGINX that I avoid Apache, if I can.
    – Sobral
    Feb 7 '14 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.