I am running a Gitlab (15.11) instance in a LAN without DNS, and want to access Gitlab Pages by IP address instead domain names. The CI/CD job for my project’s pages has completed successfully, but I am struggling to find a right way to have access to the pages with IP directly. I’ve attempted to modified /var/opt/gitlab/nginx/conf/gitlab-pages.conf
like:
server {
listen 9309;
server_name 192.168.1.100; # gitlab itself can be accessed with http://192.168.1.100:9092
server_tokens off;
disable_symlinks on;
access_log /var/log/gitlab/nginx/gitlab_pages_access.log gitlab_access;
error_log /var/log/gitlab/nginx/gitlab_pages_error.log error;
location / {
root /var/opt/gitlab/gitlab-rails/shared/pages;
index index.html;
}
error_page 403 /403.html;
error_page 404 /404.html;
}
and access my project’s pages through http://192.168.1.100/<group>/<subgroup>/<project>/public/#/
but got a 404 error. BTW, the gitlab instance and the gitlab-runner are running on the same host machine.
Does any body could help me to figure out? If this is possible, what is the correct procedure?
This isn’t going to work. Nginx doesn’t know how to differentiate traffic meant for Gitlab than to Gitlab Pages. The IP address is the same that you are attempting to use for main Gitlab repository access, as well as for Pages access. Either you need to use DNS, or you would need to give your machine multiple IP addresses to differentiate what is meant to be traffic for Gitlab, and what is meant to be traffic for Gitlab pages - and configure that accordingly. However I wouldn’t recommend it. Preferred methods are to use DNS.
Also, Gitlab runner is not meant to be ran on the same server as Gitlab. This is explicitly mentioned in the Gitlab documentation not to do that. You should be using separate machines/VM’s for Gitlab and Gitlab Runner.
All configuration changes should be made in /etc/gitlab/gitlab.rb
not by manually editing files under /var/opt/gitlab
since when you reconfigure Gitlab again, it will overwrite the changes you attempted to make manually by doing it the incorrect way.
Look at Gitlab official documentation for how to configure Gitlab, Gitlab Pages, Gitlab Runner etc and follow this exactly as it says.
I had read all the stuff about gitlab pages in docs but didn’t find anything about accessing gitlab pages through IP addresses, this is why I dug into nginx config file. I expected that nginx was able to differentiate the traffic with different ports.
Setting up a DNS and a virtual machine is cumbersome for a small dev team. I could access gitlab via a private IP, but why doesn’t it work with pages? Is it that difficult technically? After all, how can I access pages using IP address if I have a second IP or even a separate physical machine for it? All I want is a non-DNS solution but found nothing in the official documents.