Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't Work with nginx #1

Open
drfsupercenter opened this issue Nov 19, 2013 · 10 comments
Open

Doesn't Work with nginx #1

drfsupercenter opened this issue Nov 19, 2013 · 10 comments

Comments

@drfsupercenter
Copy link

This used to work great for me when I used Apache with Magento Enterprise Edition, but since switching our HTTP daemon to NginX, it no longer works. I have the nginx configuration set to do URL rewrites of everything else - if I set them to "yes" in the admin panel, there's no index.php in the storefront, if I turn it off, the index.php shows back up.

I'd be happy to share my nginx configuration if that helps.

@clockworkgeek
Copy link
Owner

Forgive me for not understanding, isn't the point to remove "index.php" when rewrites are on? What you are describing sounds like it is working right.

@drfsupercenter
Copy link
Author

Right, I'm saying URL rewrites themselves work - for the front-end. In the backend, whether your extension's enabled or not, I still see the index.php.

@clockworkgeek
Copy link
Owner

I've thought about it and there cannot be a problem with your nginx configuration since it works on the front end. Even though you have almost certainly tried the following please make sure you have cleared the cache, recompiled if compilation is enabled, checked permissions for this extension's files so PHP may read them.

I have some experience with nginx so will attempt to recreate the same problem you see.

@drfsupercenter
Copy link
Author

If it helps, here's my nginx configuration file for that domain.

http://pastebin.com/SnF1H1n5

So the URL rewrites seem to work on the front end, just not the backend.

@clockworkgeek
Copy link
Owner

I have been trying configurations on nginx and have not yet come up with a scenario where backend rewrites are handled differently to frontend.

I realise there is one thing I did not ask you to check. Go to System > Configuration > Admin > Admin Base URL then change Allow URL rewrites to Enable.

@drfsupercenter
Copy link
Author

Yeah, it's set to Enable. However, for example, when I'm on that page, the URL I get is:
http://[mydomain].com/index.php/admin/system_config/edit/section/admin/

So clearly the index.php is still there. I'm not sure if this is just a problem with my configuration or not... maybe you could try the nginx configuration I provided and see if that causes the same problem I'm getting - if so, it's probably a configuration problem in nginx and I'd love to know how to fix it.

@clockworkgeek
Copy link
Owner

I used your configuration as the basis for a test server which worked perfectly first time. I saw basis because, understandably, there were some environmental differences.

BTW, you should check your denied files are actually being blocked because this section looks badly written:

location ~ (^/(app/\|includes/\|lib/\|/pkginfo/\|var/\|report/config.xml)\|/\.svn/\|/\.git/\|/.hta.+) {
 deny all; #ensure sensitive files are not accessible
}

A \| means a literal pipe character, not an alternation. I expect it should look more like this:

# All hidden files are forbidden, no need to list them all
location ^~ ^/(app|includes|lib|pkginfo|var)/|^/report/config.xml|/\. {
 deny all; #ensure sensitive files are not accessible
}

Similarly location ~* \.(jpeg\|jpg\|gif\|png\|css\|js\|ico\|swf)$ would never match a file in practice. Not that is matters because that section does the same thing as elsewhere, it passes unmatched requests to a PHP handler. You could remove it and nothing would change.


The reason the page you look at has the URL http://[mydomain].com/index.php/admin/system_config/edit/section/admin/ is because that is the URL in the menu you clicked on. nginx is not responsible for that menu so no server configuration can change it's contents.

Try manually deleting index.php/ from the address bar of your browser and the page will still work OK because nginx is OK. All the links on that page still have index.php in them so clicking any will take you to another URL with index.php in it. This "Admin Rewrites" extension attempts to rectify that and to do it the file app/code/community/Clockworkgeek/Adminrewrites/Model/Store.php must execute.

If there was an accident during install that file might have been left out so it never got copied into place. Or perhaps it exists but doesn't have read permission. Or perhaps another extension conflicts with that file because it also tries to override Mage/Core/Model/Store.php (which is at the crux of the URL problem). This is why I mentioned compilation above because if enabled before installing Admin Rewrites this file would be ignored.

@drfsupercenter
Copy link
Author

OK, so the page loads fine if I remove the index.php, but all the links still have index.php.

Are you saying I should disable compilation, then install the extension? I have the compiler enabled.

@clockworkgeek
Copy link
Owner

Since you have the compiler enabled you should run the compilation process again.

@drfsupercenter
Copy link
Author

Yeah, I used the Magento Connect Manager to install the extension with the compiler enabled and it still doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants