{"id":106,"date":"2016-10-01T02:44:43","date_gmt":"2016-10-01T02:44:43","guid":{"rendered":"http:\/\/codestrian.com\/?p=106"},"modified":"2017-02-16T01:57:18","modified_gmt":"2017-02-16T01:57:18","slug":"hosting-your-gitlab-behind-a-reverse-proxy-server","status":"publish","type":"post","link":"https:\/\/codestrian.com\/index.php\/2016\/10\/01\/hosting-your-gitlab-behind-a-reverse-proxy-server\/","title":{"rendered":"Hosting your gitlab behind a reverse proxy server"},"content":{"rendered":"<p>Recently, I have decided to use a reverse proxy server to handle all the servers that I am hosting.\u00a0This helps to mitigate the use of port number behind the url. e.g. <strong>http:\/\/mydomain:12345<\/strong>. Some of you, who tried to do that for a gitlab server, has probably realized that the urls generated by your gitlab are incorrect.<\/p>\n<p>For example, your gitlab server uses <strong>external_url: 192.168.1.100:12345<\/strong>, and your reverse proxy points <strong>http:\/\/mydomain<\/strong> to <strong>192.168.1.100:12345<\/strong>. Despite the masking of IP using reverse proxy server, the urls generated for the project continues to use <strong>192.168.1.100:12345<\/strong>, which is probably not accessible from the internet.<\/p>\n<p>Below is the solution to the problem.<\/p>\n<pre><code>sudo -e \/etc\/gitlab\/gitlab.rb<\/code>\r\n<\/pre>\n<p>set external_url. In my case, I m using the LAN address.<\/p>\n<pre><code>external_url 'http:\/\/192.168.2.12:7000'<\/code><\/pre>\n<p>Next, navigate to <em>\/var\/opt\/gitlab\/gitlab-rails\/etc<\/em>, open gitlab.yml and change the following parameters<\/p>\n<pre><code>host: mydomain\r\nport: 80 \r\nhttps: false\r\n<\/code><\/pre>\n<p>Restart your gitlab and you will be able to see the changes.<\/p>\n<pre><code>sudo gitlab-ctl restart\r\n<\/code><\/pre>\n<p>WARNING: DO NOT USE <strong>sudo gitlab-ctl reconfigure<\/strong>. This will override the changes that you have just made.<\/p>\n<p><strong>update<\/strong><br \/>\nFor those of you that are using Apache to act as a proxy server, it seems that you will need to have external_url to be the same as your proxy url. This is necessary for those running gitlab CI.<br \/>\nHere are the steps to do that. instead of setting your external_url to your LAN address, you may use your TLD that is being used by your Apache. <\/p>\n<pre><code>external_url 'http:\/\/codestrian.com'<\/code><\/pre>\n<p>in the same file, change the following settings<\/p>\n<pre><code>web_server['username'] = 'www-data'\r\nweb_server['group'] = 'www-data'\r\nnginx['enable] = false\r\ngitlab_git_http_server['listen_network'] = \"tcp\"\r\ngitlab_git_http_server['listen_addr'] = \"localhost:7000\"<\/code><\/pre>\n<p>Reconfigure gitlab<\/p>\n<pre><code>gitlab-ctl reconfigure<\/code><\/pre>\n<p>In the update, I have assumed that you have prior knowledge on how to configure a proxy server using Apache.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, I have decided to use a reverse proxy server to handle all the servers that I am hosting.\u00a0This helps to mitigate the use of port number behind the url. e.g. http:\/\/mydomain:12345. Some of you, who tried to do that for a gitlab server, has probably realized that the urls [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,9],"tags":[13],"_links":{"self":[{"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/posts\/106"}],"collection":[{"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/comments?post=106"}],"version-history":[{"count":7,"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/posts\/106\/revisions"}],"predecessor-version":[{"id":145,"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/posts\/106\/revisions\/145"}],"wp:attachment":[{"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/media?parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/categories?post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/tags?post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}