[Nginx][Gogs] 通过 nginx 服务 gogs
[Nginx][Gogs] Serving gogs through nginx
我正在 运行 解决通过 Nginx 在我的树莓派上设置 Gogs 的问题。
我只想能够重定向 http://raspberry-ip-address:3000 to http://raspberry-ip-address/gogs。
在我的 nginx 虚拟主机配置文件下面:
server {
listen 80;
server_name localhost;
location /gogs/ {
proxy_pass http://localhost:3000;
}
}
当我访问 http://raspberry-ip-address:3000 时,我从 gogs 获取了安装页面 -> 所以 Gogs 运行良好。
当我继续访问 http:// raspberry-ip-address/gogs 时,出现 404 未找到错误。但是来自 Gogs 的日志不知何故 "reacting" 因为我得到 :
[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;
}
注意 /
和 url 的和。
HTTP 重定向 (30x) 不能 解决问题,因为它会重定向到 localhost
而不是 raspberry pi 而是 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;
}
}
}
我正在 运行 解决通过 Nginx 在我的树莓派上设置 Gogs 的问题。
我只想能够重定向 http://raspberry-ip-address:3000 to http://raspberry-ip-address/gogs。
在我的 nginx 虚拟主机配置文件下面:
server {
listen 80;
server_name localhost;
location /gogs/ {
proxy_pass http://localhost:3000;
}
}
当我访问 http://raspberry-ip-address:3000 时,我从 gogs 获取了安装页面 -> 所以 Gogs 运行良好。
当我继续访问 http:// raspberry-ip-address/gogs 时,出现 404 未找到错误。但是来自 Gogs 的日志不知何故 "reacting" 因为我得到 :
[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;
}
注意 /
和 url 的和。
HTTP 重定向 (30x) 不能 解决问题,因为它会重定向到 localhost
而不是 raspberry pi 而是 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;
}
}
}