I am trying to configure my Ubuntu 18.04 VPS to run both as an nginx webserver and private gitea server. I have the configuration mostly working except for any 404 from my domain gets passed through to gitea and shows the gitea 404. I would prefer any users of the main domain not be directed to Gitea.
Objective:
- Any subdomain except for git.domain.com should not be proxied to Gitea and should use https (working)
- Any errors for subdomains except git.domain.com should not go to Gitea (not working)
- git.domain.com should provide https access to gitea (working)
Tried:
- Using location /git/ for Gitea to separate the two and allowing the location / to return 404 after trying url. This causes all kinds of problems with 404 errors in Gitea and or causes git.domain.com to not use nginx
domain sites-enabled configuration:
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
}
Any help is greatly appreciated. Thank you.