我有一个使用nginx和docker部署的应用程序,现在我添加了第二个也使用docker所以,这将是这种情况
DOCKER_METEOR_APP1
DOCKER_METEOR_APP2
两者都在同一服务器SERVER_IP
中http://SERVER_IP/DOCKER_METEOR_APP1
http://SERVER_IP/DOCKER_METEOR_APP2
我的NGINX配置就是这样:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# HTTP
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name MY_COOL_SERVER;
location /DOCKER_METEOR_APP1 {
proxy_pass http://SERVER_IP:8001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $remote_addr;
if ($uri != '/') {
expires 30d;
}
}
location /DOCKER_METEOR_APP2 {
proxy_pass http://SERVER_IP:8002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $remote_addr;
if ($uri != '/') {
expires 30d;
}
}
}
问题?
每次我尝试访问一个或其他应用程序时,我都会收到页面标题和错误...似乎是尝试从根路径加载内容,如
http://SERVER_IP.com/hjas867651877e1u9812931.css?...
我做错了什么?有什么解决方案吗?
答案 0 :(得分:0)
Okey ......我对这个问题的解决方案
ENV ROOT_URL http://127.0.0.1/DOCKER_METEOR_APP1
lib/startup.js
Meteor.startup(function() {
process.env.ROOT_URL = 'http://127.0.0.1/DOCKER_METEOR_APP1/';
});
const history = useBasename( createHistory )(
{ basename: '/DOCKER_METEOR_APP1' }
)
<Router history={history}>