Node JS
  • SetUp Node&NVM
  • Folder Structure
  • Setup NodeJS Project
  • Library
    • Awilix
    • Swagger
    • Express
    • Jest
      • Supertest
    • Prettier
    • Eslint & Tslint
      • Tslint & Prettier
      • Tslint Plugin Prettier
      • Config With Airbnb
    • Husky And Friends
    • Sentry
  • INFRASTRUCTURE
    • Docker
      • Docker image
      • Docker container
      • Docker Volume
      • Docker command
      • Docker Compose
      • Problem & Solution
    • SonarQube
      • How to use in Nodejs
    • NGinX
    • ดูเพิ่มเติม
  • Note
    • .env declare type
    • Learn Link
Powered by GitBook
On this page
  1. INFRASTRUCTURE

NGinX

ซอฟต์แวร์โอเพนซอร์สสำหรับ Web service แบบ Revert Proxy, Load Balance, Streaming และ Other

Revert Proxy

สร้าง docker image ของ nginx

#Dockerfile
FROM nginx:latest

ไฟล์ docker compose

#docker-compose.yml
version: '3.4'
services:
    nginx:
        image: nginx
        container_name: nginx
        networks:
            - load-balancer
        volumes:
            - ${PWD}/default.conf:/etc/nginx/conf.d/default.conf:ro
        build:
            context: .
            dockerfile: ./Dockerfile
        ports:
            - "8888:80"
networks:
  load-balancer:
    driver: bridge
    name: server_load_balancer

ไฟล์ config ตัว nginx เพื่อทำ revert proxy

#default.conf
server {
        location /authenendpoint/ {
                proxy_set_header Host $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_pass http://weblinkauthen:5001/;
        }
}
PreviousHow to use in NodejsNextดูเพิ่มเติม

Last updated 3 years ago

proxy_pass http://weblinkauthen:5001/ weblinkauthen : เป็นเหมือน alias ที่รู้จักกันภายใน network เดียวกันจะสามารถใช้แทน IP ได้

Nginx: Everything about proxy_passDEV Community
วิธีการ config proxy_pass
Logo
ดูการ config ได้ ที่นี่