【问题标题】:golang/apache/cgi on debian --- apache redirects stopped workingdebian 上的 golang/apache/cgi --- apache 重定向停止工作
【发布时间】:2020-05-27 14:34:43
【问题描述】:

由于高清崩溃而重新安装后,我的重定向已停止工作。为什么?我能看到的唯一区别是根目录从 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

传递更改后 url 的 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))

}

【问题讨论】:

    标签: apache go url-rewriting cgi


    【解决方案1】:

    试图找出我的旧配置和新配置之间的区别。我终于记得第一次尝试这样做时,我尝试使用 proxypass 而不是重写规则。

    一旦我启用 proxypass,问题就会自行解决,现在可以正常工作了。虽然为什么会这样,但我不知道我没有使用代理传递,并且重写不应该依赖于它。

    sudo a2enmod 代理 && sudo a2enmod proxy_http

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

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

    【讨论】:

      猜你喜欢
      • 2016-08-12
      • 2020-09-13
      • 2014-03-30
      • 2011-05-26
      • 2015-03-10
      • 2014-07-04
      • 1970-01-01
      • 2011-08-04
      • 1970-01-01
      相关资源
      最近更新 更多