【问题标题】:Gitea and Nginx ConfigurationGitea 和 Nginx 配置
【发布时间】:2019-02-10 21:26:04
【问题描述】:

我正在尝试将我的 Ubuntu 18.04 VPS 配置为同时作为 nginx 网络服务器和私有 gitea 服务器运行。除了我的域中的任何 404 被传递到 gitea 并显示 gitea 404 之外,我的配置大部分都在工作。我希望主域的任何用户都不要被定向到 Gitea。

目标:

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

试过了:

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

启用域站点的配置:

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

}

非常感谢任何帮助。谢谢。

【问题讨论】:

    标签: nginx vps ubuntu-18.04 gitea


    【解决方案1】:

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

    要在子文件夹git.example.com/git 中运行 Gitea,Nginx 配置应该是这样的:

    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 配置中

    [server]
    PROTOCOL         = http
    DOMAIN           = git.example.com/gitea
    HTTP_PORT        = 3000
    ROOT_URL         = https://git.example.com/gitea
    

    【讨论】:

      猜你喜欢
      • 2020-12-31
      • 2018-09-09
      • 2014-07-23
      • 2014-11-03
      • 1970-01-01
      • 1970-01-01
      • 2019-11-27
      • 2018-08-31
      • 2021-08-14
      相关资源
      最近更新 更多