root에 설치된 Nginx의 커스텀으로 생성한 Config

cd /etc/nginx/sites-available/themint.conf
# themint.conf

server {
  listen 80;
  server_name i9b306.q.ssafy.io; 
  return 301 https://i9b306.q.ssafy.io$request_uri;
}

server {
  listen 443 ssl http2;
  server_name i9b306.q.ssafy.io;

  ssl_certificate /etc/letsencrypt/live/i9b306.q.ssafy.io/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/i9b306.q.ssafy.io/privkey.pem;
  
  location / {
    proxy_pass <http://localhost:3000>;
  }

  location /api1/ { 
    proxy_pass <http://localhost:8080/>; 
    # proxy_redirect off;
    charset utf-8;

    proxy_http_version 1.1;
    proxy_set_header Connection "upgrade";
    proxy_set_header Upgrade $http_upgrade;
    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-NginX-Proxy true;
  }

  location /api2/ {
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $http_host; 
  proxy_set_header X-NginX-Proxy false;
  proxy_pass <https://i9b306.q.ssafy.io:8443/>;
  proxy_redirect off;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_set_header Access-Control-Allow-Origin *;
 }
}

React 내부 Nginx Config

# react 컨테이너 접속
docker exec -it react /bin/bash
cd /etc/nginx/conf.d
server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

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

    #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;
    #}
}

ex url) http://example.com/foo/bar/baz

확인 사항 : location에서의 ‘/’ 유무, proxy_path에서의 ‘/유무’2

location 뒤 proxy_pass 뒤 URI가 proxy_path에 있는 경우 프록시 서버로 전달되는 path
Case1 location ^~ /foo {
proxy_pass http://localhost:3000;
} X X X /foo/bar/baz
Case2 location ^~ /foo/ {
proxy_pass http://localhost:3000;
} O X X /foo/bar/baz
Case3 location ^~ /foo {
proxy_pass http://localhost:3000/;
} X O X //bar/baz
/을 안붙히니 뒤에 부분까지 빼앗기는 듯
Case4 location ^~ /foo/ {
proxy_pass http://localhost:3000/;
} O O X /baz/bar
Case5 location ^~ /foo/ {
proxy_pass http://localhost:3000/foo;
} O O O /foobar/baz
Case6 location ^~ /foo {
proxy_pass http://localhost:3000/foo;
} X O O /foo/bar/baz
Case7 location ^~ /foo {
proxy_pass http://localhost:3000/xxx;
} X O 매칭되지 않는 패턴 /xxx/bar/baz
Case8 location ^~ /foo {
proxy_pass http://localhost:3000/foo/;
} X O 뒤에 추가적으로 / 가 있는 경우 /foo//bar/baz