Skip to content

nginx sub-path documentation #8635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
donpdonp opened this issue Oct 22, 2019 · 3 comments
Closed

nginx sub-path documentation #8635

donpdonp opened this issue Oct 22, 2019 · 3 comments
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/docs This PR mainly updates/creates documentation

Comments

@donpdonp
Copy link

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.

@stale
Copy link

stale bot commented Dec 21, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Dec 21, 2019
@lunny lunny added type/docs This PR mainly updates/creates documentation issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented labels Dec 26, 2019
@stale stale bot removed the issue/stale label Dec 26, 2019
@defulmere
Copy link

This is what works for me for http://domain.com/git/ (running nginx/1.16.1 and Gitea version 1.8.3+2-g11f6ed4f8 built with go1.12.6 : bindata, sqlite, sqlite_unlock_notify):

server {
    listen 80;
    server_name domain.com ;

location /git/ {
    proxy_pass http://localhost:3000/;
    }
}

Without the trailing slash on proxy_pass everything was 404.

@techknowlogick
Copy link
Member

As shown by @defulmere ROOT_URL needs to be updated to have path as well, when using nginx with subpath. Which is also what documentation has https://docs.gitea.io/en-us/reverse-proxies/ and as such I will close this ticket.

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/docs This PR mainly updates/creates documentation
Projects
None yet
Development

No branches or pull requests

4 participants