简体   繁体   中英

Meteor, Angular routes, Nginx and SSL - how to route /path to another server with rewrite

I have:

  • DigitalOcean VPS
  • Meteor application with routing in Angular
  • Nginx as a reverse-proxy
  • SSL for my domain, configured with Nginx (also redirecting http to https)
  • another hosting (!) with Wordpress blog there
  • something doma.in with DNS set to DigitalOcean VPS and Meteor app is there

How can I "rewrite" doma.in/blog to the blog, but with this same URL? (without redirect).

Try this nginx configuration:

location  ^/blog {
  rewrite /blog(.*) $1  break; #cut the /blog path
  proxy_pass         http://blog.com:8000; #then pass it to the blog domain/port
  proxy_redirect     off;  #without redirecting 
  proxy_buffering off;    #or buffering
}

As for angular, it simply needs to avoid/skip the route, as discussed here on SO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM