【问题标题】:Can Nginx proxy a specific URL to conceal the directory of a script file?Nginx 可以代理特定的 URL 来隐藏脚本文件的目录吗?
【发布时间】:2019-09-22 14:56:47
【问题描述】:

我想使用 Matomo(自托管跟踪软件,类似于 Google Analytics)。 JS sn-p 公开了一个 PHP 文件,该文件被调用以进行跟踪(例如,参见 here)。此 PHP 文件与登录文件和其他文件位于同一文件夹中,即这会为恶意爬虫暴露太多信息。因此,我想通过不存在或误导性的路径将 URL 代理到 PHP 文件。例如

不安全:

_paq.push(['setTrackerUrl', u+'https://www.mytracker.com/exposed_installation/matomo.php']);

应该变得更安全:

_paq.push(['setTrackerUrl', u+'https://www.mytracker.com/non-existing-path/matomo.php']);

所以这样爬虫只能看到跟踪脚本文件,但其他一切都会导致 404。

这可能吗?感谢您的任何建议!

【问题讨论】:

  • 为什么不使用recommanded nginx configuration
  • 我会很刻薄。我在您的帖子中看到两个问题。两者都可以回答是。
  • @Yanis-git 谢谢。据我判断,这仅保护内部文件,但仍允许爬虫查看登录页面等,请参阅location ~ ^/(index|matomo|piwik|js/index|plugins/HeatmapSessionRecording/configs)\.php {
  • @qräbnö 好吧,那我也很刻薄,邀请你回答这两个问题。

标签: nginx matomo


【解决方案1】:

请尝试 Matomo Tracker Proxy https://github.com/matomo-org/tracker-proxy

【讨论】:

    【解决方案2】:

    未经测试。

    location ~ ^/external/matomo\.php$
    {
        …
    }
    
    location ~ ^/hidden_blablahblahblablubb/(?:index|matomo|piwik|js/index|plugins/HeatmapSessionRecording/configs)\.php$
    {
        …
    }
    

    如果matomo.php 需要其他文件,您可以使用更多(命名的)locations,也可以使用 Nginx 定位命令 internalrewrite 结合使用。

    【讨论】:

      猜你喜欢
      • 2023-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-17
      • 2016-08-08
      相关资源
      最近更新 更多