vteams / open-source-billing

Open Source Billing a super simple way to create and send invoices and receive payments online.
http://opensourcebilling.org
GNU General Public License v3.0
731 stars 402 forks source link

Problem with nginx settings #66

Closed cryptoprof closed 5 years ago

cryptoprof commented 7 years ago

I have installed open-source-billing with succes, but have a little problem with nginx. When my config looks like this:

upstream app {
    # Path to Unicorn SOCK file, as defined previously
    server unix:/home/shared/sockets/unicorn.sock fail_timeout=0;
}

server {
    listen 81;
    server_name localhost;
    root /home/user/open-source-billing/public;
    try_files $uri/index.html $uri @app billing/@app;
    location ~/(.*)$ {
        proxy_pass http://app;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
}

all works perfect over localhost:81 When i need to proxy_pass on 80 port, i add to config next:

server{
    listen 80;
    server_name localhost;
    root /home/patrick/public_html;
    index index.php index.html index.htm index.nginx-debian.html;
    try_files $uri $uri/ /index.php?$args ;

    location / {
        try_files $uri $uri/ =404;
    }

    location ^~ /billing/ {
        rewrite ^/billing/(.*)$ /$1 break;
        proxy_pass http://localhost:81/;
        proxy_redirect     off;
        proxy_set_header   Host $host;
    }
}

So, when i go to localhost/billing billing opens, but withou css. And links goes to root without billing. Does have anywhere in config atribute, where can i add this prefix? Thank you for your great software and sorry for my bad english!

Promaethius commented 5 years ago

Assets are not statically declared by the rendered templates. Besides that, I see several problems with your nginx configuration. So let's start with that.

Implementing a loopback interface via TCP adds overhead to your application. You can cut out the middleman by doing a proxypass from the upstream pool to localhost/billing.

Because it's only your js and CSS assets which aren't loading, try opening your network capture interface when you're loading the site. I'm sure several 404 or 403 errors will pop up. This is because the rails application correctly renders the index relative to where it thinks you'll access it. Because of all the passthroughs and hostname setup, it'll probably be pointing to localhost/assets. This is no fault of OSB. I'd recommend either configuring another nginx location block to correspond to the error pathing or reconfigure OSB.