2016-11-15 52 views
0

我已經部署與nginx的和搬運工某個應用,現在我添加的第二個也與搬運工是這樣,這將是如此METEOR,NGINX子路徑錯誤

DOCKER_METEOR_APP1

DOCKER_METEOR_APP2

兩者都是在同一臺服務器SERVER_IP

http://SERVER_IP/DOCKER_METEOR_APP1

http://SERVER_IP/DOCKER_METEOR_APP2

MY 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

歐凱......我解決這個問題

  • 新增ROOT_URL給各應用上

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}>