You are not logged in.

#1 2024-07-06 19:28:13

AngelBePro
Member
From: Bulgaria
Registered: 2023-07-27
Posts: 63

[SOLVED] Nginx shows welcome page instead of gitlab page

I am trying to set up gitlab with nginx, but every time I try to visit the root of my domain, i see the welcome to nginx page. I am migrating from apache as my web server to nginx. I still don't know exactly how to configure but this is what my config files are like. I also followed the arch wiki, but I think its outdated since http2 is a directive and in the config example its not.
/etc/nginx/nginx.conf:

#user http;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/zadruweite.duckdns.org-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/zadruweite.duckdns.org-0001/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}



    server {
    if ($host = zadruweite.duckdns.org) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen       80;
        server_name  zadruweite.duckdns.org;
    return 404; # managed by Certbot


    }

}

/etc/nginx/sites-enabled/gitlab -> /etc/nginx/sites-avaiable/gitlab:

server {
  listen 80;                  # IPv4 HTTP
  listen 443 ssl;              # uncomment to enable IPv4 HTTPS + HTTP/2
  http2 on;
  #listen [::]:80;            # uncomment to enable IPv6 HTTP
  #listen [::]:443 ssl http2; # uncomment to enable IPv6 HTTPS + HTTP/2
  server_name zadruweite.duckdns.org;

  access_log  /var/log/gitlab/nginx_access.log;
  error_log   /var/log/gitlab/nginx_error.log;

  #ssl_certificate ssl/example.com.crt;
  #ssl_certificate_key ssl/example.com.key;

  location ~ ^/(assets)/ {
    root /usr/share/webapps/gitlab/public;
    gzip_static on; # to serve pre-gzipped version
    expires max;
    add_header Cache-Control public;
  }

  location / {
      # unlimited upload size in nginx (so the setting in GitLab applies)
      client_max_body_size 0;

      # proxy timeout should match the timeout value set in /etc/webapps/gitlab/puma.rb
      proxy_read_timeout 60;
      proxy_connect_timeout 60;
      proxy_redirect off;

      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;

     #proxy_set_header X-Forwarded-Ssl on;

      proxy_pass http://gitlab-workhorse;
  }

  error_page 404 /404.html;
  error_page 422 /422.html;
  error_page 500 /500.html;
  error_page 502 /502.html;
  error_page 503 /503.html;
  location ~ ^/(404|422|500|502|503)\.html$ {
    root /usr/share/webapps/gitlab/public;
    internal;
  }
    ssl_certificate /etc/letsencrypt/live/zadruweite.duckdns.org-0001/fullchain.pem; # managed by certbot
    ssl_certificate_key /etc/letsencrypt/live/zadruweite.duckdns.org-0001/privkey.pem; # managed by certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by certbot
}

Last edited by AngelBePro (2024-07-06 21:29:24)


Thanks for helping me!
MB: MSI B560M-A PRO
CPU: i5-10400F
GPU: RX 7800 XT

Offline

#2 2024-07-06 21:28:56

AngelBePro
Member
From: Bulgaria
Registered: 2023-07-27
Posts: 63

Re: [SOLVED] Nginx shows welcome page instead of gitlab page

Turns out it was gitlab-workhorse that was not working properly. I just did systemctl restart gitlab-workhorse and the issue went away.


Thanks for helping me!
MB: MSI B560M-A PRO
CPU: i5-10400F
GPU: RX 7800 XT

Offline

Board footer

Powered by FluxBB