我是nginx的新手,我正在尝试在家用服务器上的相同ip下运行多个应用程序。 想法是使用这样的域:
subdomain.domain.com/app1 --->转到服务器本地主机上的应用程序:3000(即subdomain.domain.com:3000) subdomain.domain.com/app2 --->转到服务器本地主机上的应用程序:3001
尤其是因为从美学上讲,没有端口会更好,而且我也没有一种可以正常工作的配置。 我目前使用此配置,但是app2无法正常工作,我也不知道为什么,以查看是否有人可以照亮。一声问候。 最底层是Windows10上的struct目录。
#####################################################################
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 443;
server_name subdominio.dominio.com www.subdominio.dominio.com;
ssl on;
ssl_certificate /Users/SERVER/Desktop/nginx/nginx-1.14.0/ssl/certificate.crt;
ssl_certificate_key /Users/SERVER/Desktop/nginx/nginx-1.14.0/ssl/certificate.key;
access_log /Users/SERVER/Desktop/nginx/nginx-1.14.0/logs/nginx.vhost.access.log;
error_log /Users/SERVER/Desktop/nginx/nginx-1.14.0/logs/nginx.vhost.error.log;
# this works perfect
location / {
proxy_pass http://127.0.0.1:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# here load index.html that would offer the app2, but not connect to the server
location /app2/ {
proxy_pass http://127.0.0.1:3001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}
this is the directory structure, windows 10
1:[在此处输入图片描述]