Skip to content

nginx sub-path documentation  #8635

Closed
Closed
@donpdonp

Description

@donpdonp

The setup experience can be greatly improved if the docs include the common configuration of a reverse proxy that handles SSL and uses a sub-path. Currently the docs are setup to make this difficult. Two changes to fix this are:

Default app.ini currently

PROTOCOL = http 
ROOT_URL  = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/

Using the PROTOCOL variable conflates the listening port (http) with the external url (https). The naieve edit is to make PROTOCOL = https. This results in immediate failure becuase gitea is now listening as tls and looks for a tls key file.

It would be more more clear if the example app.ini were something like ROOT_URL = https://example.com/ to avoid the temptation of editing PROTOCOL (this could be named better to reflect that its the listening protocol but thats another issue)

Note: the app.ini from the web install process does not use the %(PROTOCOL)s form of the ROOT_URL but the gitea first-run does create an app.ini with such a ROOT_URL.

Adding a path to ROOT_URL such as '/git' would be the next edit for an admin installing gitea in a sub-path.

At this point gitea is rewriting URLs with https://example.com/git and listening on a port without tls. So far so good. The reverse proxy docs at https://docs.gitea.io/en-us/reverse-proxies/ say for a subpath to use proxy_pass http://localhost:3000/; # Note: Trailing slash note this does not work. example.com/git/user/word will be passed as /word and not /user/word. Only the final path part gets passed to proxy_pass. Whats needed is to remove only the added /git part.

  location /git/ {
    rewrite ^/git/(.*) /$1  break;
    proxy_pass http://127.0.0.1:3000$uri$is_args$args;
  }

Note: another approach which would move the complexity from nginx into gitea is to removing the trailing slash proxy_pass http://127.0.0.1:3000 so that gitea gets all of /git/user/word and then gitea can use the ROOT_URL to determine that /git/ is extraneous.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/confirmedIssue has been reviewed and confirmed to be present or accepted to be implementedtype/docsThis PR mainly updates/creates documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions