gpt4 book ai didi

nginx - 如何更改 nginx 站点 url

转载 作者:行者123 更新时间:2023-12-01 16:42:38 25 4
gpt4 key购买 nike

下面给出了我的 ngix 站点配置文件(/etc/nginx/sites-enabled/)。现在我可以通过 localhost 访问此站点,但我想知道如何将站点 URL 更改为 localhost/gitlab。我需要为不同的网站保留 localhost

upstream gitlab {
server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
}

server {
# listen *:80 default_server; # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea
server_name localhost; # e.g., server_name source.example.com;
server_tokens off; # don't show the version number, a security best practice
root /home/git/gitlab/public;

# individual nginx logs for this gitlab vhost
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log;

location / {
# serve static files from defined root folder;.
# @gitlab is a named location for the upstream fallback, see below
try_files $uri $uri/index.html $uri.html @gitlab;
}

# if a file, which is not found in the root folder is requested,
# then the proxy pass the request to the upsteam (gitlab unicorn)
location @gitlab {
proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_redirect off;

proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;

proxy_pass http://gitlab;
}
}

最佳答案

更新:GitLab 现在对相对 URL 和专用文档提供了更好的支持:

<小时/>

您想要将 GitLab 移动到相对 URL 中。请记住,除了 nginx 配置之外,您还必须更改其他 3 个地方的 url。请参阅 gitlab.yml 中的说明:

# Uncomment and customize the last line to run in a non-root path
# WARNING: This feature is known to work, but unsupported
# Note that three settings need to be changed for this to work.
# 1) In your application.rb file: config.relative_url_root = "/gitlab"
# 2) In your gitlab.yml file: relative_url_root: /gitlab
# 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"

所有这些配置都位于 /home/git/gitlab/config 下。

关于nginx - 如何更改 nginx 站点 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20023573/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com