Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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.
Your config does not look really clean. Have a look here https://linuxserversetup.com/tutorial/self-hosted-git-service#nginx-forwarding-with-https and scroll down to "Change Nginx configuration file to HTTPS".
To run Gitea in a subfolder git.example.com/git
, the Nginx config should be like this:
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/;
# ...
And in the Gitea config accordingly
[server]
PROTOCOL = http
DOMAIN = git.example.com/gitea
HTTP_PORT = 3000
ROOT_URL = https://git.example.com/gitea
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.