@Richard Duke / @scott boss :
If there’s enough interest, then perhaps we could give a presentation on NGINX as part of a future VXUG meeting. In the meantime, here’s a quick overview…
Let’s suppose that you’re running your Xojo standalone Web app on the server using port 64000, like this:
./my-xojo-app --port=64000 &
And suppose that you want the app to be available externally via ports 8081 and 8082. In your NGINX config file, you could setup a server block like this:
server {
listen 8081;
listen 8082;
location / {
proxy_pass http://127.0.0.1:64000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass_request_headers on;
}
}
This tells NGINX to listen for requests on ports 8081 and 8082, and pass them to http://127.0.0.1:64000, along with the host info, any HTTP headers that were specified, and the remote IP address (as a header named “X-Forwarded-For”).
So that single instance of the Xojo Web app, which internally is listening on port 64000, will be available externally on ports 8081 and 8082. You could, of course, configure NGINX to listen on additional ports if you’d like, as well as host names.
Another nice feature of NGINX is that you can have it handle redirects from http to https, and SSL termination as well. For example…
[code]server {
server_name my-domain-name.com;
listen 80;
return 301 https://$server_name$request_uri;
}
server {
server_name my-domain-name.com;
listen 443 ssl;
ssl_certificate /home/ec2-user/meh/certificate/chained.my-domain-name.com.crt;
ssl_certificate_key /home/ec2-user/meh/certificate/my-domain-name.com.key;
location / {
proxy_pass http://127.0.0.1:64010;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass_request_headers on;
}
}[/code]
The first server block tells NGINX to listen for requests for my-domain-name.com on port 80, and returns a 301 response, indicating that the client should send the request to the secure URL instead.
The second server block tells NGINX to listen for requests for my-domain-name.com on port 443. It also specifies the SSL certificate and key files. And it passes the request to an app listening internally on port 64010.
There’s a lot more that NGINX can do, but I think this covers some of the more commonly used features - and things that Xojo developers might be interested in.
Anyway, I hope this helps. And if you are interested in learning more, let me know.