[solved] nginx proxy_pass to directory

  • Hello, I would like to have a quasar frontend hidden behind nginx proxy in a way that https authentication is terminated and handled by nginx webserver at https://domain/quasar and then is beeing proxied internally to http://localhost:8090 where I run quasar app itself.

    Normally this is being done via proxy_pass setting in nginx, but it does not work. I think I need to set some proxy_set_header as well, but do not know how. Is this possible?

    http://domain:8090 works fine, but that is not what I need… Many thanks for your help / thoughts!

  • Been There done that. Have it working, You need to set a custom proxy path for your app. I am sure you’ve looked into this https://quasar-framework.org/guide/app-api-proxying.html . So let’s say you choose the path api/ so your api will be accessible at https://localhost:8090/api/ . The only header you need to forward form the nginx proxy_pass is the ip address. Rest every other header is sent automatically. So you will need to add proxy_set_header remote_addr $remote_addr; to your nginx config in the proxy.

  • Yes, but not really. I meant to run Quasar itself in a path like https://domain/quasar not / root directory as usual. In other words, running /quasar the same as /api (with node.js backed) and /vuetify (with another frontend) etc. All that on one domain. Cannot make it work…

    As a workaround I decided to change the logic in a way, that every frontend gets own subdomain like: frontend1.domain.org and frontend2.domain.org - that is fine since every frontend gets it own root and works as designed.

    But. That means new Nginx configuration, new https certificate, … the pain I hoped to avoid.

  • OK, I am an idiot. Nginx proxy_pass to directory works fine with Quasar (using beta10). It just needs to be specified as “location /quasar/” with trailing / as explained at https://stackoverflow.com/questions/26449466/nginx-proxy-pass-to-a-directory

    Plus “publicPath” in quasar.conf.js needs to be adjusted to.

    my nginx config:

    location /quasar/ {
    proxy_pass http://localhost:8090;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header X-Real-Ip $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_set_header REMOTE_ADDR $remote_addr;


    quasar.conf.js configuration:

    devServer: {
    publicPath: “/quasar/”,

    Hope it helps somebody.

Log in to reply