我正在处理一个问题,在我的覆盆子上设置Gogs通过Nginx。
我只想能够将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:// raspberry-ip地址:3000时,我从gogs ->获得安装页面,因此Gogs运行良好。
当我在http:// raspberry-ip地址/gogs上访问时,我得到了一个404未找到的错误。然而,Gogs的日志在某种程度上是“反应”的,因为我得到:
[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没有正确地重定向请求。知道吗?
(谢谢;)
发布于 2016-08-25 06:57:56
对于我来说,下面的配置工作正常:
location /gogs/ {
proxy_pass http://localhost:3000/;
}但是,下面(您发布的内容)会产生您提到的错误:
location /gogs/ {
proxy_pass http://localhost:3000;
}注意/和url的和。
HTTP重定向(30x)不能解决这个问题,因为它将重定向到localhost,它不是raspberry pi,而是执行请求的计算机。
/etc/nginx/nginx.conf中的完全nginx
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://stackoverflow.com/questions/39123861
复制相似问题