简体   繁体   English

有没有一种方法可以限制外部用户访问我的服务器文件

[英]Is there a way to restrict the external users to access my server files

Is there a way to restrict the external users to access my server files.. 有没有一种方法可以限制外部用户访问我的服务器文件。

example is when i access this dir http://puptaguig.net/evaluation/js/ it shows the 404 page(though it's not obvious) but when i tried to view control.js here http://puptaguig.net/evaluation/js/controls.js it opened up.. 例如,当我访问该目录http://puptaguig.net/evaluation/js/时,它显示404页面(尽管不明显),但是当我尝试在此处查看control.js时http://puptaguig.net/evaluation/ js / controls.js它打开了。

   IndexIgnore *
   <Files .htaccess>
   order allow,deny
   deny from all
   </Files>

i just want to make these files inside my server directory to secured from outside viewing for some reasons..but how? 由于某些原因,我只想使这些文件位于服务器目录中,以防止从外部查看。.但是如何?

Best Regards.. 最好的祝福..

siegheil/js? siegheil / JS? Should be siegheil/ns for sure? 应该确定为siegheil / ns吗?

You could chmod 000 and then no one would see them or access them. 您可以使用chmod 000,然后没人会看到或访问它们。 You can't have people accessing and not seeing them at the same time. 您不能让人们同时访问和看到他们。 Can't be done. 不能做

You can add below lines to your httpd.conf or. htaccess 您可以将以下httpd.conf or. htaccess行添加到httpd.conf or. htaccess httpd.conf or. htaccess this will avoid access of your JavaScripts httpd.conf or. htaccess这将避免访问您的JavaScripts

<Files ~ "\.js$">
 Order allow,deny
 Deny from all   
 Satisfy All     
</Files>

The only way I can think to manage this is deny access to your js files by throwing a .htaccess in the siegheil/js/ folder that says something along the lines of: 我认为可以管理此问题的唯一方法是,在siegheil/js/文件夹中抛出一个.htaccess,拒绝访问您的js文件,该文件的内容siegheil/js/如下:

deny from all

or just simply put your code in a folder above the root document level of the site itself. 或者只是将您的代码放在网站本身根文档级别上方的文件夹中。

After that, you then use something like minify to retrieve the js files from the backend (PHP / some other server language side) and have the minified / obfuscated code placed in another folder or just outputted directly from the script. 之后,您可以使用minify之类的方法从后端(PHP /其他服务器语言方面)检索js文件,并将经过简化/混淆的代码放在另一个文件夹中,或者直接从脚本中输出。

With all that said, in the end, the js code must be downloaded one way or another to be run by the browser. 综上所述,最后,必须以一种或另一种方式下载js代码才能由浏览器运行。 This will make it impossible to prevent people from looking at your code and figuring out what it does if they really want to. 这将使得无法阻止人们查看您的代码并弄清他们的实际意愿。

You were able to access http://puptaguig.net/evaluation/js/controls.js but not http://puptaguig.net/evaluation/js/ because most Apache installs prevent an anonymous user from viewing the directory contents, and only permit access to specific files in the directory. 你是能够访问http://puptaguig.net/evaluation/js/controls.js但不http://puptaguig.net/evaluation/js/因为大多数Apache的安装防止匿名用户查看目录内容,只允许访问目录中的特定文件。

There is no way "hide" client-side JS because without access to those files your users will not be able to run your script. 无法“隐藏”客户端JS,因为如果没有访问这些文件的权限,您的用户将无法运行您的脚本。 As suggested by @General Redneck, you can obfuscate and minify your js using a tools like minify or uglifyJS , but those can, potentially, been un-minified (minification is still a good idea for performance reasons). 正如@General Redneck所建议的那样,您可以使用minifyuglifyJS之类的工具来混淆和最小化js,但可能未实现最小化(出于性能方面的考虑,缩小仍然是一个好主意)。 Ultimately you are fighting against the "open" nature of the web. 最终,您要与Web的“开放”性质作斗争。 I'd suggest putting a license on your code, and keeping an open mind : ) 我建议在您的代码上放一个许可证,并保持开放的态度:)

If you really need something to be secure, try accomplishing the essential functionality (which you want to keep private) with a backend language like php or asp.net and feeding the relevant data to you JS script. 如果您确实需要确保安全的内容,请尝试使用诸如phpasp.net类的后端语言来完成基本功能(您希望使其私有),并将相关数据提供给JS脚本。

You should create an .htaccess file in the relevant directory that has 您应该在具有以下内容的相关目录中创建一个.htaccess文件:

-Indexes

in it. 在里面。 This will prevent listing of the directory and will cause a 403 error to be raised. 这将阻止目录列表,并导致出现403错误。 Your application can then handle that however it wants to display whatever you want. 然后,您的应用程序可以处理它,但是它希望显示您想要的任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM