Reputation: 2457
I confused on how to rewrite the URL for meteorjs requests that has a http address of http://IP/<LettersHere>meteor_js_resource=true
to http://IP:3000/<LettersHere>meteor_js_resource=true
.
If I access my site's URL:3000, then I can get all the static files from the meteor application.
However, if I tried this nginx configuration file to route URL:3000
to URL/someURL
so when people access my site, they don't need the 3000 port number, but instead /someURL
:
server {
listen 0.0.0.0:80;
server_name domain.com;
location /youtube-channel-search
{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:3000;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
rewrite http://domain.com http://domain.com:3000 permanent;
}
}
Then I get an error where the js file cannot be found:
This is correct, since http://IP/URL
is not http://IP:3000/URL
.
How should I rewrite the incoming requests to add an extra port :3000? I thought the proxy_pass automatically takes care of this.
Thanks
Upvotes: 0
Views: 283
Reputation: 2457
I figured it out.
You will need to change ROOT_URL environmental parameter of the meteorJS application to localhost:3000/youtube-channel-search
.
Using the same nginx.conf would work.
This is because some of the sockjs and static files are mapped to the localhost:3000
, without the trailing /youtube-channel-search
.
Upvotes: 1