首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gitea和Nginx组态

Gitea和Nginx组态
EN

Stack Overflow用户
提问于 2019-02-10 21:26:04
回答 1查看 746关注 0票数 3

我正在尝试配置我的Ubuntu18.04VPS作为nginx and服务器和私有gitea服务器运行。除了域中的404被传递到gitea并显示gitea 404之外,我的配置大部分都在工作。我希望主域的任何用户都不要被引导到Gitea。

目标:

  • 除git.domain.com以外的任何子域都不应代理到Gitea,而应使用https (工作)。
  • 除git.domain.com以外的子域的任何错误都不应该转到Gitea (不工作)
  • git.domain.com应该提供https对gitea的访问(工作)

试过:

  • 使用location /git/ for Gitea将两者分开,并允许在尝试url后返回404。这会导致Gitea出现各种问题,导致404错误,或者导致git.domain.com不使用nginx。

域站点-启用配置:

代码语言:javascript
复制
server {

    root /var/www/example.com/html;
    index index.html index.htm index.nginx-debian.html;

    server_name git.example.com;
    location / {
            proxy_pass https://0.0.0.0:3000;
    }
server_name *.example.com;
location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
    deny all;
}
    #location / {
    #        try_files $uri $uri/ =404;
    #}

listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate <path>/fullchain.pem; # managed by Certbot
ssl_certificate_key <path>/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

任何帮助都是非常感谢的。谢谢。

EN

回答 1

Stack Overflow用户

发布于 2022-02-03 10:53:21

您的配置看起来不太干净。在这里查看https://linuxserversetup.com/tutorial/self-hosted-git-service#nginx-forwarding-with-https并向下滚动到“将Nginx配置文件更改为HTTPS”。

要在子文件夹git.example.com/git中运行Gitea,Nginx配置应该如下所示:

代码语言:javascript
复制
server {
  listen      443 ssl http2;
  listen      [::]:443 ssl http2;
  server_name git.example.com;

  root        /var/www/example.com/html;
  index       index.htm;

  location / {
    try_files $uri $uri/ /index.htm;
  }

  location /git/ {
    proxy_pass http://localhost:3000/;
  }

  # ...
}

因此,在Gitea配置中

代码语言:javascript
复制
[server]
PROTOCOL         = http
DOMAIN           = git.example.com/gitea
HTTP_PORT        = 3000
ROOT_URL         = https://git.example.com/gitea
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54621221

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档