У меня следующая проблема. Я хочу получить доступ к конечным точкам API в этой настройке. Яйцо.
локальный: 9000 / API / ссылки
Однако, когда запрос набирается так, nginx перенаправляет запрос, и я в конечном итоге здесь
локальный: 9000 / ссылки
Когда я использую трейлинг вперед, этого не происходит.
локальный: 9000 / API / ссылки /
# Upstream are linked to the docker-compose services
# and must match their name and port
upstream api {
server api:9000;
}
upstream app {
server app:80;
}
upstream dashboard {
server dashboard:80;
}
server { # PROXY SERVER
listen 9000;
# the proxy server handles the traffic on
# the docker-compose network
proxy_redirect off;
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-Host $server_name;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
# This "hack" is required because normally
# it would be the root URI "/"
# but since we handle these as routes on a single
# server, we have to mess a little with that routing
location = /app { return 302 /cactus/;}
location /app/ {
proxy_pass http://app/; # note the trailing slash
}
location /dashboard { # the issue with the routing is handled in vue.config.js
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://dashboard/;
}
location = /api { return 302 /api/;}
location /api {
proxy_pass http://api; # how can I request api/links without
# trailing forward slash?( e.g.g. api/links/ <-- )
}
Я пробовал разные комбинации, но ничего не получалось. Я не хочу начинать связываться с API, так как он работает нормально, как и ожидалось.