Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what was the reason behind client-backend? #5

Closed
tonipepperoni opened this issue May 17, 2018 · 9 comments
Closed

what was the reason behind client-backend? #5

tonipepperoni opened this issue May 17, 2018 · 9 comments

Comments

@tonipepperoni
Copy link

Woudn't it be simply better to proxy a connection directly to laravel?

@laqul
Copy link
Owner

laqul commented May 18, 2018

@tonipepperoni The reason for this file is to keep the client_secret used in the authentication out of the client and the refresh token in an http-only cookie.

@tonipepperoni
Copy link
Author

@laqul Ok I see, so basically you are following: http://esbenp.github.io/2017/03/19/modern-rest-api-laravel-part-4/

Basically only auth related issues need to use the proxy, everything else doesn't require the proxy correct?

In production an nginx configuration should pipe all /backend requests to the client-back end and all graphql requests to the api ? Am I correct?

@laqul
Copy link
Owner

laqul commented May 21, 2018

@tonipepperoni Hello! the proxy within the client is only needed in the development environment because by default the client runs on localhost:8080 and client-backend runs on localhost:8001. In a production environment run the quasar build (more info in Quasar Framework official site) command inside the client folder and a dist folder is created, the contents of this folder must be uploaded to the root server folder, then create a new folder in the server root folder called backend and put the index.php (client-backend) file in it. The laravel API can be placed on the same server in a subdomain or on another server.
In production the proxy is dont needed.

example server estructure:
public_html
----backend
--------index.php <--(client-backend)
----fonts
----img
----js
----statics
----*.css
----index.html

Sorry for my english.

@tonipepperoni
Copy link
Author

Ok got you. Thanks.

I'll make a nginx conf and upload it here. Might also investigate build scripts to automate that process. will get back to you!

@laqul
Copy link
Owner

laqul commented May 21, 2018

Thanks!

@laqul laqul closed this as completed May 21, 2018
@mandofever78
Copy link

@tonipepperoni Did you get up and running with Nginx conf on this setup? About to dive into it myself

@tonipepperoni
Copy link
Author

@mandofever78 no, I didn't get around to it! Because basically i figured it was much better to write a login system that uses graphql.
BTW @laqul you should really consider implementing laravel lighthouse graphql over the folkloreatelier package! It's 20x better!

@laqul
Copy link
Owner

laqul commented Jun 28, 2018

@tonipepperoni Thanks for the suggestion. I don't have enough time available at the moment, but help is appreciated.

@mandofever78
Copy link

FYI - working Nginx config with SSL enabled for production deployment as described above with api located in subfolder of root:

server {
    listen 80;
    server_name your_domain.com;
    rewrite ^/(.*) https:/your_domain.com/$1 permanent;
}

server {

  server_name your_domain www.your_domain.com;

  root /var/www/your_domain.com/current;
  index index.html index.php;

  location / {
    try_files $uri $uri/ /index.html;
  }

  location /backend {
    alias /var/www/your_domain.com/backend;
    try_files $uri $uri/ @nested;

    location ~ \.php$ {
      include snippets/fastcgi-php.conf;
      fastcgi_param SCRIPT_FILENAME $request_filename;
      fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
    }
  }

  location @nested {
    rewrite /nested/(.*)$ /nested/index.php?/$1 last;
  }

  location ~ /\.ht {
    deny all;
  }

  listen 443 ssl;
  ssl_certificate /etc/ssl/certs/your_domain.com.crt.pem;
  ssl_certificate_key /etc/ssl/certs/your_domain.com.pem;

}

server {

    server_name api.your_domain.com;
    root /var/www/your_domain.com/api/public;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    error_page 404 /index.php;

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }

    listen 443 ssl;
    ssl_certificate /etc/ssl/certs/your_domain.com.crt.pem;
    ssl_certificate_key /etc/ssl/certs/your_domain.com.pem;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants