Answer the question
In order to leave comments, you need to log in
How to set up 2 locations with proxy_pass?
Hello!
I'm trying to separate requests into api and dev . Each location proxies to its own application.
nginx config file:
server {
listen 80;
listen [::]:80;
server_name some.domain;
server_tokens off;
root /var/www/html;
location /api {
proxy_pass_request_headers on;
proxy_pass http://localhost:1337;
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 /dev {
proxy_pass_request_headers on;
proxy_pass http://localhost:1338;
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 {
rewrite ^ /api([0-9a-z]*) $1 break;
proxy_pass_request_headers on;
proxy_pass http://localhost:1337;
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;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question