server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name www.sub-1.domain.com sub-1.domain.com;
root /var/www/sub-1.domain.com;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://localhost:2000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name www.sub-2.domain.com sub-2.domain.com;
root /var/www/sub-2.domain.com;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
/api/sub1
и т.д - используй его server {
listen 80 default_server;
server_name www.domain.com domain.com;
location /api/sub1 {
# Убрать sub1, что бы запрос шел на http://localhost:2000/api
proxy_pass http://localhost:2000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /api/sub2 {
# Убрать sub2, что бы запрос шел на http://localhost:3000/api
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
server {
listen 80;
server_name www.client-subdomain-1.domain.com client-subdomain-1.domain.com;
location / {
тут отдаёшь клиент
}
}
server {
listen 80;
server_name www.client-subdomain-2.domain.com client-subdomain-2.domain.com;
location / {
тут отдаёшь клиент
}
}
server {
listen 80;
server_name www.api-1.domain.com api-1.domain.com;
location /api {
proxy_pass http://localhost:2000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
server {
listen 80;
server_name www.api-2.domain.com api-2.domain.com;
location /api {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
return I18nMiddleware(request);
когда ты из браузера отправляешь запрос - прикрепляешь куки, но щас ты отправляешь запрос с сервера на другой сервер