Debian 上的 golang/apache/cgi --- Apache 重定向停止工作



由于高清崩溃而重新安装后,我的重定向已停止工作。为什么?我能看到的唯一区别是根目录从 var/www 更改为 var/www/html。我尝试将/var/www 指定为根目录,同时指定/var/www/。如果我关闭 ssl,我的默认 conf 具有相同的指令,我会遇到同样的问题。

我正在使用 ssl 并且我的 000-default-le-ssl.conf 包含

ServerAdmin webmaster@localhost
DocumentRoot   / var/www/html
<Directory  /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.yellowrockonline.com.au [OR]
RewriteCond %{SERVER_NAME} =yellowrockonline.com.au
RewriteRule ^(wiki)$ https://www.yellowrockonline.com.au/cgi-bin/mywikicgi 
RewriteRule ^(view/.*)$ http://localhost:8080/$1 [P,L] 
RewriteRule ^(edit/.*)$ http://localhost:8080/$1 [P,L] 
RewriteRule ^(save/.*)$ http://localhost:8080/$1 [P,L]
</Directory>
# Redirect "/view/suggestion" http://localhost:8080/view/suggestion 
# works but returns localhost:8080/ to the browser 
The cgi program starts from a link to www.domainname/cgi-bin/programname and returns domainma,e/view/suggestion to the browser along with the error

在此服务器上找不到请求的 URL。 Apache/2.4.38 (Debian( 服务器位于 www.yellowrockonline.com.au 端口 443

指向 CGI 程序的链接 https://www.yellowrockonline.com.au/cgi-bin/mywikicgi

提供更改后的网址的 go 代码

func hello(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/view/suggestion", http.StatusFound) 
// added to do redirect
fmt.Fprintf(w, "Hello from Go!  Redirecting to suggestions")
}
func main() {
http.HandleFunc("/view/", makeHandler(viewHandler))
http.HandleFunc("/edit/", makeHandler(editHandler))
http.HandleFunc("/save/", makeHandler(saveHandler))
http.HandleFunc("/", hello)
cgi.Serve(nil)
log.Fatal(http.ListenAndServe(":8080", nil))
}

试图找出我的旧配置和新配置之间的区别。 我终于想起了我第一次尝试这样做时,我尝试使用代理通行证而不是重写规则。

一旦我启用代理传递,问题就会自行修复,它现在正在工作。 虽然为什么会这样,但我不知道我没有使用代理通行证,重写不应该依赖于它。

sudo a2enmodproxy && sudo a2enmod proxy_http

你猜怎么着! 它解决了问题,现在可以工作了! 我又开心了!

我添加了一个额外的重定向,以阻止人们看到正在运行的 cgi 程序的名称。

最新更新