# Using Apache HTTPD with a sub-path as a reverse proxy

**URL:** <https://forum.gitea.com/t/using-apache-httpd-with-a-sub-path-as-a-reverse-proxy/1987>\
**Category:** Install/Maintain/Configure\
**Created:** [March 8, 2020, 11:12am UTC](https://forum.gitea.com/t/using-apache-httpd-with-a-sub-path-as-a-reverse-proxy/1987 "2020-03-08T11:12:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![finjh](https://avatars.discourse-cdn.com/v4/letter/f/3be4f8/32.png) [@finjh](https://forum.gitea.com/u/finjh)\
**Post date:** [March 8, 2020, 11:12am UTC](https://forum.gitea.com/t/using-apache-httpd-with-a-sub-path-as-a-reverse-proxy/1987/1 "2020-03-08T11:12:32Z")

</div>

I am trying to establish the following setup.  
At home, 1 node hosts both apache httpd and gitea. The home firewall lets through https only.

Home PCs =\> gitea own serving of http on port 3000.  
Outside access =\> https://_PublicName_/git

I intend to have apache handle https and convert that to simple http to talk gitea.  
Here is the VirtualHost

> \<VirtualHost \_default\_:443\>  
> DocumentRoot “/var/www/html”  
> ServerName _PublicName_:443  
> ServerAlias _PublicName_  
> AllowEncodedSlashes NoDecode  
> \<Location /git\>  
> Require all granted  
> ProxyPass [http://localhost:3000/](http://localhost:3000/) nocanon  
> ProxyPassReverse [http://localhost:3000/](http://localhost:3000/)  
> \</Location\>  
> \</VirtualHost\>

When from outside, the user accesses https://_PublicName_/git, I get a poorly formatted page  
Also, when the uses clicks “Sign in”, the URL that link targets is

> https://_PublicName_/user/login?redirect\_to=  
> This is wrong because there should ‘/git’ in it.

What should ROOT\_URL be in app.ini?

---

<div class="post-metadata">

**Author:** ![guillep2k](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/guillep2k/32/646_2.png) [@guillep2k](https://forum.gitea.com/u/guillep2k)\
**Post date:** [March 11, 2020, 10:44pm UTC](https://forum.gitea.com/t/using-apache-httpd-with-a-sub-path-as-a-reverse-proxy/1987/2 "2020-03-11T22:44:41Z")

</div>

I think that this configuration is not supported; AFAIK Gitea requires `/` as the root path. What I’d suggest is to set up a server alias and redirect over there. For example:

server: `dev.company.com`  
intended path: `dev.company.com/git`  
actual path: `git.company.com`

`git.company.com` points to the same server as `dev.company.com`, and uses the same certificate, which contains the `git` alias. Anyone accessing `dev.company.com/git` should be permanently redirected over `git.company.com`.

This of course requires manual administration of the server’s certificate to include the alias, but it’s supported by Let’s Encrypt if that’s what you’re using.

---

<div class="post-metadata">

**Author:** ![finjh](https://avatars.discourse-cdn.com/v4/letter/f/3be4f8/32.png) [@finjh](https://forum.gitea.com/u/finjh)\
**Post date:** [March 12, 2020, 8:45am UTC](https://forum.gitea.com/t/using-apache-httpd-with-a-sub-path-as-a-reverse-proxy/1987/3 "2020-03-12T08:45:15Z")

</div>

I have setup a dns alias cname to point to [dev.company.com](http://dev.company.com).

> This of course requires manual administration of the server’s certificate to include the alias, but it’s supported by Let’s Encrypt if that’s what you’re using.

I do use Let’s Encrypt, how do I update the certificate then?

---

<div class="post-metadata">

**Author:** ![jolheiser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/jolheiser/32/4807_2.png) [@jolheiser](https://forum.gitea.com/u/jolheiser)\
**Post date:** [March 12, 2020, 1:24pm UTC](https://forum.gitea.com/t/using-apache-httpd-with-a-sub-path-as-a-reverse-proxy/1987/4 "2020-03-12T13:24:21Z")

</div>

Hello, you can check out our [reverse proxy documentation](https://docs.gitea.io/en-us/reverse-proxies/#using-apache-httpd-with-a-sub-path-as-a-reverse-proxy) for instructions on using a sub-URL in Apache.

---

<div class="post-metadata">

**Author:** ![finjh](https://avatars.discourse-cdn.com/v4/letter/f/3be4f8/32.png) [@finjh](https://forum.gitea.com/u/finjh)\
**Post date:** [March 12, 2020, 2:02pm UTC](https://forum.gitea.com/t/using-apache-httpd-with-a-sub-path-as-a-reverse-proxy/1987/5 "2020-03-12T14:02:04Z")

</div>

Yes i did, that’s how I configured my apache.  
However, I desired to access gitea from outside home, and from inside home with 2 different URLs.  
That’s what [guillep2k] explained was not quite possible  
and I am trying to pursue his solution

---

<div class="post-metadata">

**Author:** ![jolheiser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/jolheiser/32/4807_2.png) [@jolheiser](https://forum.gitea.com/u/jolheiser)\
**Post date:** [March 12, 2020, 2:03pm UTC](https://forum.gitea.com/t/using-apache-httpd-with-a-sub-path-as-a-reverse-proxy/1987/6 "2020-03-12T14:03:19Z")

</div>

Aha, my fault for not reading thoroughly. 😁

---

<div class="post-metadata">

**Author:** ![finjh](https://avatars.discourse-cdn.com/v4/letter/f/3be4f8/32.png) [@finjh](https://forum.gitea.com/u/finjh)\
**Post date:** [March 12, 2020, 2:21pm UTC](https://forum.gitea.com/t/using-apache-httpd-with-a-sub-path-as-a-reverse-proxy/1987/7 "2020-03-12T14:21:27Z")

</div>

> [@guillep2k](#):
>
> AFAIK Gitea requires `/` as the root path

from the reverse proxy doc, a /git suffix is possible

> [server] ROOT\_URL = [http://git.example.com/git/](http://git.example.com/git/)

---

<div class="post-metadata">

**Author:** ![finjh](https://avatars.discourse-cdn.com/v4/letter/f/3be4f8/32.png) [@finjh](https://forum.gitea.com/u/finjh)\
**Post date:** [March 15, 2020, 7:57pm UTC](https://forum.gitea.com/t/using-apache-httpd-with-a-sub-path-as-a-reverse-proxy/1987/8 "2020-03-15T19:57:23Z")

</div>

I drew the setup here:  
[gitea](https://docs.google.com/presentation/d/1xYtRDMCWC0ahVcReC65A4df0hhnoD0G0tuQ4w2lW5vE/edit?usp=sharing)  
It can help. what’s my next step?
