본문 바로가기
카테고리 없음

🥰 nginx -> gitlab-ce %2F 오류 처리

by Knowledge Store In Hyunsoft 2022. 6. 11.

nginx--> gitlab-ce 형태로 설치되어 있는 경우 일부 화면이 동작하지 않는 경우가 있는데

확인해보니 호출 URL에 %2F가 포함된 경우에  nginx가 %2F를 /로 해석하는 바람에 존재하지 않는 url을 호출하고 404를 리턴함.

 

EX)

설정전 샘플

http://gitlab.hyunsoft.xyz/api/v4/projects/p1%2FtestApi/repository/files/.gitlab-ci.yml/raw
http://gitlab.hyunsoft.xyz/api/v4/projects/p1/testApi/repository/files/.gitlab-ci.yml/raw

  server {
    listen 8443 ssl;
    server_tokens off;
    server_name gitlab.hyunsoft.xyz;

    # ssl
    ssl_certificate /etc/cert/server.crt;
    ssl_certificate_key /etc/cert/server.key;

    # recommendations from https://raymii.org/s/tutorials/strong_ssl_security_on_nginx.html
    ssl_protocols tlsv1.2;
    ssl_ciphers '!aNULL:kECDH+AESGCM:ECDH+AESGCM:RSA+AESGCM:kECDH+AES:ECDH+AES:RSA+AES:';
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:ssl:10m;

    # disable any limits to avoid http 413 for large image uploads
    client_max_body_size 0;

    # required to avoid http 411: see issue #1486 (https://github.com/docker/docker/issues/1486)
    chunked_transfer_encoding on;

    location / {
      proxy_pass http://gitlab-server;
      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;

      # When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings.
      proxy_set_header X-Forwarded-Proto $scheme;

      proxy_buffering off;
      proxy_request_buffering off;
    }
  }

 

설정후 샘플

http://gitlab.hyunsoft.xyz/api/v4/projects/p1%2FtestApi/repository/files/.gitlab-ci.yml/raw
http://gitlab.hyunsoft.xyz/api/v4/projects/p1%2FtestApi/repository/files/.gitlab-ci.yml/raw

 

 

  server {
    listen 8443 ssl;
    server_tokens off;
    server_name gitlab.hyunsoft.xyz;

    # ssl
    ssl_certificate /etc/cert/server.crt;
    ssl_certificate_key /etc/cert/server.key;

    # recommendations from https://raymii.org/s/tutorials/strong_ssl_security_on_nginx.html
    ssl_protocols tlsv1.2;
    ssl_ciphers '!aNULL:kECDH+AESGCM:ECDH+AESGCM:RSA+AESGCM:kECDH+AES:ECDH+AES:RSA+AES:';
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:ssl:10m;

    # disable any limits to avoid http 413 for large image uploads
    client_max_body_size 0;

    # required to avoid http 411: see issue #1486 (https://github.com/docker/docker/issues/1486)
    chunked_transfer_encoding on;

    location / {
      proxy_pass http://gitlab-server$request_uri;
      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;

      # When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings.
      proxy_set_header X-Forwarded-Proto $scheme;

      proxy_buffering off;
      proxy_request_buffering off;
    }
  }

 

 

728x90

댓글