How to change the host IP sent in emails to new GitLab users to a publicly visible IP, not the local GitLab IP?

隐身守侯 提交于 2019-12-07 15:26:32
Dan Nissenbaum

Two hints pointed the way for me, and once I did resolve the issue (as I am about to describe), I found the details laid out in the deceptively named subsection of the Bitnami GitLab stack official documentation.

The first hint was to be found in a not-very-highly-upvoted answer here (in comparison with other answers and the accepted answer, some of which had many more upvotes). The setting for the host IP and port used in the GitLab account invitation emails is to be found in the gitlab.yml file (as of today, the full path of this file on the VM stack (and probably other) installations is /opt/bitnami/apps/gitlab/htdocs/config/gitlab.yml; see the host and port settings, as well as other overall useful settings). (I'm not experienced with the Rails universe, and using the .yml settings file is a touch, apparently, of the way Rails apps in general do things, if I understand correctly.)

The above step does succeed - but only until the server is restarted. Unfortunately, when the server is restarted, the host setting is overwritten with whatever is present in ifconfig as the IP address (the port entry remains the same as whatever you enter).

The second hint was how to resolve this problem; I found it here. There is a special script in the init.d folder whose specific purpose is just to reset the host parameter in this (and perhaps other?) .yml settings files. (What a wonderful "convenience" in my scenario.) Simply commenting out the single line exec /opt/bitnami/apps/gitlab/bnconfig --machine_hostname ... in this file (by adding a # at the front of the line) resolved the problem.

Once both of the above changes were made, the problem was resolved. GitLab invitation emails successfully include the desired static IP address (and port) of the server, even through server restarts.

As I mentioned above, once I resolved the problem, I then found that the answer to this question was already laid out in the official Bitnami GitLab documentation (note: both hint #1 and hint #2, from above, are tucked away in this same subsection of the documentation - one after the other - they're not prominent; they don't stand out very well; they come across as secondary details upon first reading, I think; the formatting does not draw attention to the file name and path, which would be helpful, I think; and the subsection name in which they are present does not particularly make it clear that this would be the correct subsection to look at, except in retrospect, in my opinion).


ADDENDUM: For anyone who finds it useful, there's an added detail required to get email working from your own personal server with GitLab - I made only a brief passing mention of this in the question, because I had already done it.

But for completeness for future visitors, I should mention that you need to set up SMTP properly on your GitLab instance by making a modification to a file named production.rb (the full path as of today is /opt/bitnami/apps/gitlab/htdocs/config/environments/production.rb). Specifically, as is also to be found in the official Bitnami GitLab documentation, you must add a config.action_mailer.smtp_settings {...} block and add/uncomment a few other settings in order to be able to send emails from your running GitLab instance.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!