Answer the question
In order to leave comments, you need to log in
How to make a subdomain on vps?
Good afternoon.
How can I make a subdomain for the site, if now it is arranged like this:
A node is launched in the directory root/site.ru/
at 127.0.0.1:3001 and sends the frontend through nginx.
root/api/
another node is launched in the directory at site.ru:3000 - this is apiAnswer the question
In order to leave comments, you need to log in
1. Create sites-enabled/api.site.ru.conf (don't forget to configure DNS for api.site.ru)
2. Write something like this in it:
server {
listen 443 ssl;
listen [::]:443 ssl;
access_log /var/log/nginx/api.site.ru_access.log;
ssl_certificate /etc/ssl/api.site.ru.crt;
ssl_certificate_key /etc/ssl/api.site.ru.key;
server_name api.site.ru;
root /root/api.site.ru;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
location / {
# тут заголовки и др.
proxy_pass http://127.0.0.1:3000; # Тут адрес ноды которая отдает API (уже запущенная)
}
}
nginx -t
(do not forget about the certificates) Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question