我怎么不调用/index.cgi?

我怎么不调用/index.cgi?
root@technoluddites:/etc/apache2/sites-enabled# uname -a
Linux technoluddites.org 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux
root@technoluddites:/etc/apache2/sites-enabled# apachectl -v
Server version: Apache/2.4.38 (Debian)
Server built:   2019-10-15T19:53:42

我正在尝试将站点配置为 URL 缩短器。除了例外,我试图得到http://cjsh.name/foo重定向到https://cjsh.name/?foo,并有一个 index.cgi 来查看它是否有 foo 的条目,如果没有,则重定向到https://cjshayward.com/foo。我尝试修改 /index.cgi 以将诊断记录到未打开的文件中; /index.cgi 的开头内容如下:

#!/usr/bin/python

import cgi
import commands
import cPickle
import os
import re
import sys

ADMIN_URL = u'/wp-content/protected/refer_url.cgi'
CHARACTERS = \
  u'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890' + \
  u'=+/,!$*'
DEFAULT_LOCATION = u'https://CJSHayward.com/'
DEBUG_LOG = u'/tmp/cjsh.name.error'
debug = open(DEBUG_LOG, 'w')

/tmp/cjsh.name.error 永远不会被创建,并且 CGI 脚本上的 ls -ltu 列出了我上次从命令行访问该文件的时间,而不是几分钟后我尝试加载时的时间http://cjsh.name/pstv,它应该点击字典中定义的键并加载https://cjshayward.com/positive/

HTTP 站点的 Apache 配置文件运行:

<VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot /home/christos/books
        ServerName cjsh.name
        ServerAlias cjsh.cjshayward.com www.cjsh.name books.cjsh.name
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
        CustomLog /home/christos/logs/cjsh.name combined
        ErrorLog /home/christos/logs/cjsh.name.error
        RewriteEngine onhttps://www.zazzle.com/a_definion_of_the_autism_spectrum_t_shirt-235926361009257586 [R=301,L]
        RewriteRule ^/99.?[Pp][Aa][Gg][Ee].*$ https://smile.amazon.com/C-J-S-Hayward-Under-99-Pages/dp/B09H8SLCZP?_encoding=UTF8&qid=1632850210&sr=8-1&linkCode=ll1&tag=jonascorn-20&linkId=fffe9ae168e721fbc006f4096100e772&language=en_US&ref_=as_li_ss_tl [R=301,L]
        RewriteRule ^/phone\/?\.?% https://www.amazon.com/How-Take-Life-Back-Phone/dp/B0BHS7LQJV/ref=sr_1_1?crid=C9EYO4DANH6I&keywords=cjs+hayward+how+can+i+take+my+life+back+from+my+phone&qid=1670093200&sprefix=cjs+hayward+how+can+i+take+my+life+back+from+my+phonCapsC115&sr=8-1%23editorialReviews_feature_div [R=301,L]
        RewriteRule ^/([^\?].*)$ /?$1 [R=301,L]
        RewriteRule ^/$ https://cjshayward.com [R=301,L]
        <Directory /home/jonathan/stornge/>
            Options ExecCGI Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
        </Directory>
</VirtualHost>

HTTPS站点的入口是:

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin [email protected]
        DocumentRoot /home/christos/cjsh.name
        ServerName cjsh.name
        ServerAlias cjsh.cjshayward.com www.cjsh.name books.cjsh.name
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
        CustomLog /home/christos/logs/cjsh.name combined
        ErrorLog /home/christos/logs/cjsh.name.error
        RewriteEngine on
        RewriteRule ^/best.(.*)$ https://cjshayward.com/wp-content/cgi/download-ebook.cgi?book=The+Best+of+Jonathan%27s+Corner.$2 [R=301,L]
        RewriteRule ^/99.?[Pp][Aa][Gg][Ee].*$ https://smile.amazon.com/C-J-S-Hayward-Under-99-Pages/dp/B09H8SLCZP?_encoding=UTF8&qid=1632850210&sr=8-1&linkCode=ll1&tag=jonascorn-20&linkId=fffe9ae168e721fbc006f4096100e772&language=en_US&ref_=as_li_ss_tl [R=301,L]
        RewriteRule ^/phone\/?\.?% https://www.amazon.com/How-Take-Life-Back-Phone/dp/B0BHS7LQJV/ref=sr_1_1?crid=C9EYO4DANH6I&keywords=cjs+hayward+how+can+i+take+my+life+back+from+my+phone&qid=1670093200&sprefix=cjs+hayward+how+can+i+take+my+life+back+from+my+phonCapsC115&sr=8-1%23editorialReviews_feature_div [R=301,L]
        RewriteRule ^/([^\?].*)$ /?$1 [R=301,L]
        RewriteRule ^/$ https://cjshayward.com [R=301,L]
        <Directory /home/jonathan/stornge/>
            Options ExecCGI Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
        </Directory>
SSLCertificateFile /etc/letsencrypt/live/cjsh.name-0002/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/cjsh.name-0002/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

在我的主 apache2.conf 文件中,我有:

DirectoryIndex index.cgi index.php index.shtml index.html

我正在尝试通过 Mac (12.6.9) 上的 Firefox (119.0.1) 访问该网站,并关闭我网站的所有选项卡并永久删除所有浏览历史记录以重新开始。尝试访问http://cjsh.name/pstv正在重定向到https://cjshayward.com/?pstv(这是并且应该是 404 页面),自从接触了启用站点的文件后,我已经重新启动了 Apache。我也尝试过拉http://cjsh.name/pstv第一次从 Safari 访问,Safari 的行为与 Firefox 完全一样,即重定向到https://cjshayward.com/?pstv

我如何将新的电话转接到http://cjsh.name/pstvhttps://cjshayward.com/?pstv(和https://cjsh.name/?pstvhttps://cjshayward.com/?pstv)?

我应该如何更改 Apache 文件或其他设置中的一个或两个,以便调用 index.cgi,查找“初始问号右侧”数据,并重定向到(在本例中)https://cjshayward.com/positive/

- 更新 -

我在之前的条目中使用了 cjsh.name ServerAliased 搬起石头砸了自己的脚,这导致了我最初报告的行为。然而,行为上的新差异是尝试加载http://cjsh.name/pstv负载https://cjshayward.com/?pstv代替https://cjshayward.com/positive/。这恰好会加载主页而不是 404https://cjshayward.com/pstv,但这仍然是一个错误,我的主页没有加载该页面https://cjshayward.com/positive/

谢谢,

答案1

/tmp/cjsh.name.error从未被创造过

这与 Apache 没有什么关系,但与它的启动方式有关,我猜测与systemd.看一下systemdApache 的配置:

cat "$(find /etc/systemd/ -type f -iname '*apache*')"

您将看到此行,它告诉systemd我们/tmp要映射到私有临时目录而不是使用公共/tmp

PrivateTmp=true

您可以通过运行systemctl edit apache2并添加这两行来覆盖它,

[Service]
PrivateTmp=false

或者如果您只是为了调试而需要查看它,您可以查找它,

find /tmp -type f -name cjsh.name.error

但对于有意访问的数据文件,您应该仔细考虑其他选项,例如将这些非临时文件写入/tmp.

相关内容