0

I'm new at Nginx stuff. I've just migrated a website (which includes static files) from IIS to Nginx but some of my links are broken because of the case sensivity.

Please note that I've installed nginx on Debian. How can I tell Nginx these links are same :

http://s2.example.com/some/folder/kmplayer.exe
http://s2.example.com/some/folder/KmplayEr.exe

Note that I don't want to lower-case my file(s)/folder(s).. I want to make Nginx treat kmplayer.exe same as Kmplayer.exe or kmpLayeR.exe, in other words, I want to disable case sensitivity for my files..

Please help me. I've read all the articles on the internet but they didn't solve the problem.

My Server Block Configurations:

server {
listen   80;
server_name www.s2.example.com s2.example.com;
access_log /var/www/s2/logs/access.log;
error_log /var/www/s2/logs/error.log;

location / { 
    root   /var/www/s2;
    index  index.html index.htm;

}
}
  • Look here: http://stackoverflow.com/questions/18415508/how-to-make-url-case-insensitive-with-nginx – Lenniey Jan 09 '17 at 15:58
  • I did it but it doesnt work..... – Ramin King Jan 09 '17 at 15:59
  • somebody help me – Ramin King Jan 09 '17 at 16:43
  • First link just check the sub folder name, not the file name. You will need to lowercase everything is my guess. like seen there https://www.garron.me/en/bits/rename-files-from-uppercase-to-lowercase.html, and make sure all file referenced in your code are lowercase too. – yagmoth555 Jan 09 '17 at 17:07
  • No, i dont want to lower-case my file(s)/folder(s) ... I want Nginx to treat KmplayEr.exe same as kmplayer.exe . In other words, the visitor should be able to download both kmplayer.exe and KmplAyer.exe or kmPlayer.exe etc. – Ramin King Jan 09 '17 at 17:16
  • Server side it can be a problem, as the Linux itself can store KmplayEr.exe, Kmplayer.exe or KmplAyer.exe in the same folder. Which file nginx will send to the user ? – yagmoth555 Jan 09 '17 at 18:40
  • nginx should send "kmplayer.exe" to user also it should send the same file if the user entered "KmplAyer.exe" in the link address. in other words nginx should forget about case sensitivity. – Ramin King Jan 09 '17 at 18:50
  • URLs _are_ case-sensitive. It is Windows that is broken in this respect, as treating URL paths the same regardless of case is a protocol violation. Not to mention bad for SEO. You will need to fix all of your URLs. – Michael Hampton Jan 09 '17 at 18:55
  • Yes, I know Windows has broken the rule but I believe we can still do it in Nginx as well.. because in Apache there's a module called mod_speling that does the job. – Ramin King Jan 09 '17 at 19:01
  • Please just let me know "how" can I solve the problem. – Ramin King Jan 09 '17 at 19:42
  • 1
    Does this help? Are your files consistently lower case or are they random? You may find a workaround but you're better off fixing things now than letting the problem go on. http://serverfault.com/questions/380502/nginx-rewrite-url-to-lowercase-url – Tim Jan 09 '17 at 20:26
  • They are randomly lower case, that's why I can't force nginx to lower-case all the links. Why there's no module like mod_speling in Nginx? – Ramin King Jan 09 '17 at 20:40

1 Answers1

1

Haven't tried it but this might work: Install a samba server on the server and set case sensitive = False. Move your data to /var/foo. Share /var/foo though samba. Mount 127.0.0.1:/var/foo at /var/www/s2.

Mark Wagner
  • 18,019
  • 2
  • 32
  • 47
  • Thank you Mark for answering.. Can I share /var/www/s2 at the first? because there are tons of data located at /var/www/s2 and I cant move them to /var/foo. If I do like that, will Nginx and Samba work together? and another question is, will Samba cause security problems? btw, why Nginx doesn't have any modules like Apache's mod_speling? – Ramin King Jan 10 '17 at 06:16
  • 1
    You will need to configure nginx to use the samba mountpoint. How you accomplish that is up to you. If configured correctly Samba will not cause security problems. I don't know why nginx doesn't have mod_speling-like functionality. – Mark Wagner Jan 10 '17 at 20:22