Reverse Proxy, Nginx, and static files

  1. 4 years ago

    olivier v

    23 Aug 2013 Pre-Release Testers Europe (France)

    Hello all,

    If we use a reverse proxy (like Nginx) and Standalone instances,
    is it possible to let the Nginx server serve static files (images ....) instead of Standalone server?

    Thank you
    Olivier

  2. John J

    23 Aug 2013 Pre-Release Testers, Xojo Pro Cleveland, Ohio

    Yes- you can use nginx to serve static content to some requests and to pass other requests along to other servers. You can do this with different domains, subdomains or even URL paths.

    Nginx can also handle the ssl certs for the xojo apps on the front-end.

  3. John J

    23 Aug 2013 Pre-Release Testers, Xojo Pro Cleveland, Ohio

    Example based on my previous post .

    #loadbalance instances of Xojo app
    upstream myproject {
            ip_hash;
            server 127.0.0.1:8080;
            server 127.0.0.1:8081;
            server 127.0.0.1:8082;
      }
    
    #Proxies requests to the instances above
      server {
        listen 80;
        location / {
            proxy_buffering off;
            proxy_read_timeout 5m;
            proxy_pass http://myproject;
        }
    
    #Directly serve requests for mydomain.com/images/*  out of "/some/path/*" 
        location /images/ {
            alias /some/path/;
        }
      }
  4. olivier v

    23 Aug 2013 Pre-Release Testers Europe (France)

    Thank you John!

    ok, so:

    - If the user types "http://mydomain.com", Nginx will lead to one of the Xojo instances, and Xojo serve data

    - If the user types "http://mydomain.com/images/myimage.jpg" (or a HTML static page containing this image), Nginx serve directly this image

    But if the user types "http://mydomain.com", and the Xojo instance must send data containing an image (webImageView.url="http://mydomain.com/images/myimage.jpg"), is Nginx or Xojo which sends the image?

  5. John J

    23 Aug 2013 Pre-Release Testers, Xojo Pro Cleveland, Ohio
    Edited 4 years ago by John J

    @olivier v - If the user types "http://mydomain.com", Nginx will lead to one of the Xojo instances, and Xojo serve data

    Yes

    @olivier v - If the user types "http://mydomain.com/images/myimage.jpg" (or a HTML static page containing this image), Nginx serve directly this image

    Yup

    @olivier v (webImageView.url="http://mydomain.com/images/myimage.jpg"), is Nginx or Xojo which sends the image?

    In my experience, if you set the url like that you will get a normal link to an image out of Xojo, so the image would be served directly from nginx, bypassing the app entirely.

  6. Tim H

    23 Aug 2013 Pre-Release Testers Portland, OR USA

    @John J (webImageView.url="http://mydomain.com/images/myimage.jpg"), is Nginx or Xojo which sends the image?

    In my experience, if you set the url like that you will get a normal link to an image out of Xojo, so the image would be served directly from nginx, bypassing the app entirely.

    Right. Xojo sends html to the browser, which interprets it, including loading images from their url.

  7. olivier v

    23 Aug 2013 Pre-Release Testers Europe (France)

    Great! Thank you John and Tim.

or Sign Up to reply!