N
N
neolane2016-12-19 11:11:52
Nginx
neolane, 2016-12-19 11:11:52

Nginx, how to redirect from name.gitserver.io/prj/********** to name.gitserver.io/prj/?

For GitLab Pages, the config is
/etc/nginx/sites-available/gitlab-pages.conf

## GitLab
##

## Pages serving host
server {
  listen 0.0.0.0:80;
  listen [::]:80;

  ## Replace this with something like pages.gitlab.com
  server_name ~^.*\.gitserver\.io$;

  ## Individual nginx logs for GitLab pages
  access_log  /var/log/nginx/gitlab_pages_access.log;
  error_log   /var/log/nginx/gitlab_pages_error.log;

  location / {
    proxy_set_header    Host                $http_host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Proto   $scheme;
    # The same address as passed to GitLab Pages: `-listen-proxy`
    proxy_pass          http://localhost:8090/;
  }


  # Define custom error pages
  error_page 403 /403.html;
  error_page 404 /404.html;
}

How to redirect from name.gitserver.io/prj/****** to name.gitserver.io/prj/?
Or am I dripping into the wrong steppe at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
akzhan, 2016-12-20
@neolane

location ~ /prj/.+ {
    return 301 /prj/;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question