英文:
How can I deploy a Go app along with MediaWiki using Apache?
问题
我有一个由我的大学托管的网站(www.univ.edu/me
),目前我在www.univ.edu/me/wiki
下设置了一个维基,并且它运行良好。我的问题是如何部署上述Go应用程序,以便可以通过www.univ.edu/me/mygoapp
访问它?
我找到了一些解决方案,但它们似乎都需要root权限。在我的情况下,我没有root访问权限,也无法修改服务器的配置,这很可能是Apache。
**更新:**感谢您的回复。在我的情况下,Apache服务器位于与实际托管我的网站文件的机器不同的机器上。具有Apache的机器/IP拒绝ssh连接,因此没有直接的方法来检查服务器的配置。
英文:
Let's say I have the following simple Go web app:
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World")
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
I have a website which is hosted by my university (www.univ.edu/me
) and currently I have a wiki setup under www.univ.edu/me/wiki
and it works fine. My question is how I can deploy the above Go app there so it can be accessed through www.univ.edu/me/mygoapp
?
I have found some solutions but they all appear to require root privileges. In my case, I don't have root access and I'm not able to modify the configuration of server, which most likely is Apache.
Update: Thanks for your replies. It appears that in my case, the Apache server is on a separate machine than the one which physically hosts my website files. The machine/IP that has the Apache, refuses ssh connections so there's no direct way to check the server's configuration.
答案1
得分: 2
看一下Apaches mod_proxy
。当请求特定虚拟目录时,它提供代理另一个HTTP服务器:
<Location /goapp/>
ProxyPass http://localhost:8080/
</Location>
您可能需要对Apache配置进行其他更改,以确保请求正确传递。
英文:
Take a look at Apaches mod_proxy
. It offers proxying another HTTP Server when certain virtual directories are requested:
<Location /goapp/>
ProxyPass http://localhost:8080/
</Location>
You may need to do additional changes to your Apache config to make sure the request gets passed through properly.
答案2
得分: 1
如果您对MediaWiki安装中的.htaccess
文件具有写访问权限,您可以尝试添加以下内容:
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
这取决于全局Apache配置,因为mod_proxy在像大学这样的地方通常被禁用或限制,但值得一试。
有关更多详细信息,请参阅http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass和http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse。
英文:
If you have write access to the .htaccess
file in your MediaWiki installation you may be able to add:
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
This is dependant on the global Apache configuration, as mod_proxy is often disabled or restricted on premises like Universities, but it's worth a try.
See http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass and http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse for more details.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论