Hướng dẫn trên hệ điều hành Mac, Với các hệ điều hành khác làm tương tự (câu lệnh và đường dẫn khác còn file cấu hình là giống nhau).
brew install nginx
- Sửa lại nội dung file
/usr/local/etc/nginx/nginx.conf, bổ sung cấu hình vào trong khốihttp:
http {
include mime.types;
default_type application/octet-stream;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
}
- Sửa lại nội dung file
/usr/local/etc/nginx/servers/default.conf(nếu không có file này thì tự tạo):
server {
listen 9999;
client_body_buffer_size 100M;
client_max_body_size 1G;
location /api {
proxy_pass http://git.hocngay.com:9999;
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;
}
location /socket {
proxy_pass http://git.hocngay.com:9999;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
location /admin {
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://localhost:3000;
}
location / {
proxy_pass http://localhost:3001;
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;
}
}
- Phân quyền cho thư mục
client_body_tempđể upload được file (nếu báo lỗi không có file thì bỏ qua):
sudo chown -R $(whoami) /usr/local/var/run/nginx/client_body_temp- Khởi động nginx: Gõ
nginxnếu chưa khởi động, nếu đã khởi động thì reload bằng lệnhnginx -s reload. - Để bật chế độ tự khởi động nginx lúc bật máy thì start nginx bằng lệnh
brew services start nginx.
No comments:
Post a Comment