[Nginx] [Gogs]通过nginx提供服务gogs
问题描述:
我正在运行一个通过Nginx在我的树莓上设置Gogs的问题。[Nginx] [Gogs]通过nginx提供服务gogs
我只是想能够将http://raspberry-ip-address:3000重定向到http://raspberry-ip-address/gogs。
下面我nginx的虚拟主机的conf:
server {
listen 80;
server_name localhost;
location /gogs/ {
proxy_pass http://localhost:3000;
}
}
当我走在http://覆盆子IP地址:3000,我从视护目镜得到安装页面 - >所以视护目镜是捉迷藏很好。
当我在http:// raspberry-ip-address/gogs上找到404找不到的错误。然而,从视护目镜日志被莫名其妙地“反应”,因为我得到:
[Macaron] 2016-08-24 14:40:30: Started GET /gogs/ for 127.0.0.1
[Macaron] 2016-08-24 14:40:30: Completed /gogs/ 302 Found in 1.795306ms
2016/08/24 14:40:30 [D] Session ID: 8e0bbb6ab5478dde
2016/08/24 14:40:30 [D] CSRF Token: YfL58XxZUDgwim9qBCosC7EXIGM6MTQ3MTk4MDMxMzMxMTQ3MjgzOQ==
对于这里的更多信息是我的nginx/error.log中:
request: "GET /localhost HTTP/1.1", host: "192.168.1.15"
2016/08/24 14:40:30 [error] 3191#0: *4 open() "/usr/share/nginx/html/install" failed (2: No such file or directory), client: 192.168.1.12, server: localhost, request: "GET /install HTTP/1.1", host: "192.168.1.15"
在我看来,那Nginx的不正确重定向请求。任何想法 ?
感谢;)
答
对我来说,下面的配置工作:
location /gogs/ {
proxy_pass http://localhost:3000/;
}
但以下(你贴什么)产生你所说的错误:
location /gogs/ {
proxy_pass http://localhost:3000;
}
注意/
和和网址。
HTTP重定向(30X)不不解决该问题,因为它会重定向到localhost
这不是树莓PI但也不请求的计算机。
完整的nginx的conf在/etc/nginx/nginx.conf
:
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location/{
root /usr/share/nginx/html;
index index.html index.htm;
}
location /git/ {
proxy_pass http://127.0.0.1:3333/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
确实[此帖](https://serverfault.com/questions/379675/nginx-reverse-proxy-url-rewrite)帮你吗? – syntonym
不是,我试着从这篇文章的每一个答案。 如果我的nginx conf如下所示,设置正在工作: server { listen 80; server_name localhost; location/{ proxy_pass http:// localhost:3000; } } – Guillaume
那么重写不会重写URL?或者重写发生,但不知何故gog仍然会得到'/ gogs /'?即使你把它放在'/ git /'之类的其他地方,它是否会得到'/ gogs /'? – syntonym