B
B
bengur22021-10-05 17:23:12
Nginx
bengur2, 2021-10-05 17:23:12

Nginx - how to make a certain pathname be a proxy for another resource?

Two containers are locally raised on the VPS:

[email protected]:~$ curl http://localhost:27073
<!DOCTYPE html><html><head><title>Express</title><link rel="stylesheet" href="/stylesheets/style.css"></head><body><h1>Welcome to Express</h1></body></html>

[email protected]:~$ curl http://localhost:50101
<!DOCTYPE html><html><head><title>App</title><link rel="stylesheet" href="/stylesheets/style.css"></head><body><h1>Welcome to App</h1></body></html>


Nginx:
server {
    listen 80;
    server_name site.com;
    return 301 https://site.com$request_uri;
}
server {
    listen 443 ssl;
    server_name site.com;

    ssl_certificate         /etc/ssl/certs/cert.pem;
    ssl_certificate_key     /etc/ssl/private/key.pem;

    location / {
        proxy_pass http://127.0.0.1:27073;
    }

    location /apps/authors {
        proxy_pass http://127.0.0.1:50101;
    }
}


Validity:
[email protected]:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful


Restart: Expect site.com/apps/authors
[email protected]:~$ sudo systemctl restart nginx

to have an App header . But a 404 page is displayed . What is done wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vreitech, 2021-10-05
@bengur2

no character /after proxy_pass http://127.0.0.1:50101.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question