Skip to content
hyeonggyu ham edited this page Nov 14, 2019 · 1 revision

nginx

였λ₯˜λ“€

  • μ •ν™•ν•œ λΌμš°νŒ… 문제
    • location μ„€μ •
    location /api {
      proxy_pass http://server;
    }
    # 127.0.0.1/api/rooms κ²°κ³Ό : get /api/rooms
    
    location /api {
      proxy_pass http://server/;
    }
    # 127.0.0.1/api/rooms κ²°κ³Ό : get //rooms
    
    location /api/ {
      proxy_pass http://server/;
    }
    # 127.0.0.1/api/rooms κ²°κ³Ό : get /rooms
    
    # 즉 맨 μ•„λž˜ κ²°κ³Όκ°€ λ§žλ‹€.

의문

  • dockerλ₯Ό μ“°λŠ” nginx server λ‚΄μ˜ 뢄기에 따라 proxy_passμ—λŠ” μ–΄λ–€μ‹μœΌλ‘œ μ£Όμ†Œλ₯Ό λ„£μ–΄μ€˜μ•Ό ν•˜λŠ”μ§€?

    • μ°Έκ³ 
    • By default Compose sets up a single network for your app. Each container for a service joins the default network and is both reachable by other containers on that network, and discoverable by them at a hostname identical to the container name.
    • 간단 λ²ˆμ—­ : κΈ°λ³Έκ°’μœΌλ‘œ composeλ₯Ό μ‚¬μš©ν•˜λ©΄ ν•œ 개의 λ„€νŠΈμ›Œν¬μ— μ—°κ²°λœλ‹€. 각 μ»¨ν…Œμ΄λ„ˆλ“€μ€ κΈ°λ³Έ λ„€νŠΈμ›Œν¬μ— λ“€μ–΄μ˜€κ³ , ν•΄λ‹Ήν•˜λŠ” λ„€νŠΈμ›Œν¬μ—μ„œ μ„œλ‘œ μ ‘κ·Όν•  수 μžˆλ‹€. 그리고 container와 λ™μΌν•œ μ΄λ¦„μœΌλ‘œ ν˜ΈμŠ€νŠΈμ΄λ¦„μ„ 찾을 수 μžˆλ‹€.
  • upstream은 μ™œ μ‘΄μž¬ν•˜λŠ”μ§€?

    • μ•„λž˜ λ§ν¬μ—μ„œ 힌트λ₯Ό μ–»μ—ˆμŒ
    • https://gompro.postype.com/post/1735800
    • docker container 이름을 μ¨μ„œ 동일 λ„€νŠΈμ›Œν¬ 내에 μžˆλŠ” containerλ₯Ό μ°Ύμ•„μ„œ μ—°κ²°ν•˜λŠ” 것 κ°™λ‹€. 127.0.0.1이 μ•„λ‹ˆλΌ
    • upstream app {
        server server:3030; # μ„œλ²„μ˜ μ»¨ν…Œμ΄λ„ˆ λͺ…
      }
      
      server {
        listen 80;
      
        location / {
          proxy_pass http://app;
        }
      }
      
Clone this wiki locally