【问题标题】:index.php not working with TOR nginxindex.php 不适用于 TOR nginx
【发布时间】:2017-08-25 15:15:42
【问题描述】:

全部。 我正在使用带有 nginx 和 php5-fpm 的 debian。我让网站功能齐全,然后安装 Tor 来创建和洋葱网站。我成功地将其配置为加载 index.html,但是,当我使用 index.php 时,Tor 浏览器不显示该页面。相反,Tor 浏览器会下载 index.php。我不确定我需要进行哪些配置。我这样做的目的是为了学习。我不关心安全性或真正使用 .onion 网站。这让我很困扰,虽然没有弄清楚。谢谢你。

这是我在 /etc/nginx/sites-available/ 中的服务器块配置

server {
listen 127.0.0.1:80;

root /var/www/html/;
index index.php index.html index.htm;
server_name 4bgxjb2vkb7tvsgw.onion;

location / {
 try_files $uri $uri/ =404;
 }

location ~ \.php$ {
 root /var/www/html/;
 include snippets/fastcgi-php.conf;
 fastcgi_pass unix:/var/run/php5-fpm.sock;
 fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
 }

location ~ /\.ht {
 deny all;
 }
}

sn-ps/fastcgi-php.conf:

# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;

# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php;
include fastcgi.conf;

感谢您的帮助!

【问题讨论】:

  • curl -v localhost 在服务器上给你什么?
  • Connection: keep-alive < ETag: "59a030bc-137" < Accept-Ranges: bytes < <?php // Version define('VERSION', '2.3.0.2'); // Configuration if (is_file('config.php')) { require_once('config.php'); } // Install if (!defined('DIR_APPLICATION')) { header('Location: install/index.php'); exit; } // Startup require_once(DIR_SYSTEM . 'startup.php'); * Connection #0 to host localhost left intact
  • snippets/fastcgi-php.conf的内容是什么?将其添加到问题中
  • 如果现有的 PHP 站点已经在运行,为什么不将洋葱地址添加到 server_name 块中呢? server { server_name domain.com onionaddr.onion; ... }

标签: php nginx debian tor


【解决方案1】:

试试这样的:

 location / {
    try_files $uri $uri/ =404;
}
error_page 401 403 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
} 

error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /usr/share/nginx/html;
}

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-05
    • 2013-11-09
    • 1970-01-01
    • 2013-12-14
    • 2018-10-02
    • 2017-10-17
    • 2016-06-28
    相关资源
    最近更新 更多