Reputation: 2153
I have a single domain name from my university, where I have a service running:
server {
listen 443 default_server ssl;
server_name example.uni.com;
keepalive_timeout 70;
ssl_certificate xxx.crt;
ssl_certificate_key xxx.key;
location / {
proxy_pass http://localhost:8081;
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;
}
}
What I would like to achieve, is to have the example.uni.com/specificaddress
point to a different service running on a different localhost port, without having to modify the service running on 8081 (even nicer would be a specificaddress.example.uni.com
, but I believe I cannot do that myself). How would this be possible? Simple creating another server with server_name
set to example.uni.com/specificaddress
doesn't work unfortunately (not a big suprise, it is handled by the service running on 8081).
Upvotes: 2
Views: 5211
Reputation: 26667
You can add a new location block with the proxy pass the different port.
Example
location / {
proxy_pass http://localhost:8081;
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 /specificaddress {
proxy_pass http://localhost:8082;
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;
}
Upvotes: 5