1

I'd like to use Nginx to serve both my Rails (using passenger) and an Angular front end.

Basically, all requests that goes to / should be directed to Rails and every request that goes to /admin/* should be redirected to a Angular App.

I've found this question that would theoretically be exactly what I'm looking for. Unfortunately Dmitry's answer is a bit vague for someone (like me) who doesn't know much (next to nothing) about Nginx.

EDIT: Here's the Nginx configuration that I have tried:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name 178.62.92.199;
    passenger_enabled on;
    passenger_app_env development;
    root /var/www/netturing/public;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location ~ ^/admin/ {
            proxy_pass http: /var/www/client/admin;
    }

    location / {
            proxy_pass http: /var/www/netturing/public;
    }

}

Could someone extend the answer a bit?

Thanks!

1 Answer 1

1

I think haproxy it's a better tool to do this.

But I have some rails apps in standalone passenger server with nginx in front.

My suggested nginx config:

server {

  # some config directives
  ...

  # Al turrón !

  # Angular App
  location ~ ^/admin/ {
    proxy_pass http://<URI TO ANGULAR APP>;
  }

  # Rails App
  location / {
    proxy_pass http://<URI TO RAILS APP>;
  }
}
Sign up to request clarification or add additional context in comments.

5 Comments

Unfortunately that didn't work. I've updated my question with a code snippet.
In essence, the question it's better formuled and detailed and the question it's exactly the same in both cases with a little bit differences.
I agree the questions are pretty much the same, however I did not understand the answer, nor the code snippet given as answer. In such case, what would you have me do?
Dmitry explain rightly, you must declare locations for @ruby and @angular, but do try_files first.
Your location sections appear a little wrong. you must configure the proxy section to app server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.