Answer the question
In order to leave comments, you need to log in
How to set up proxying in nginx for several applications?
There are 3 running node.js applications
1. NUXT (client side) at 127.0.0.1:3000
2. API (express.js) at 127.0.0.1:8080
3. NUXT (admin panel) at 127.0.0.1:3001
In nginx I write:
location / {
proxy_pass http://127.0.0.1:3000;
}
location /api/v1 {
proxy_pass http://127.0.0.1:8080;
}
location /admin {
proxy_pass http://127.0.0.1:3001;
}
Answer the question
In order to leave comments, you need to log in
Hello.
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
send_timeout 300;
proxy_read_timeout 300;
proxy_connect_timeout 300;
gzip on;
gzip_vary on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/json;
server {
listen 80;
if ($scheme = https) {
return 301 http://$host$request_uri;
}
}
server {
listen 80;
server_name localhost ************ 127.0.0.1;
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
location / {
root /usr/share/nginx/html/;
index index.html;
}
location /api {
proxy_pass http://rest:8080/api;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
proxy_redirect off;
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question