This is the continuation of another post where I asked how to be able to setup one server and forward - redirect requests to other different servers running Xojo webapps.
I am now fighting with Nginx, which I installed on a windows server.
This is what I want to achieve:
www.mydomain.com.ar --> Landing page
www.mydomain.com.ar/1 --> App 1 at xxx.xxx.xxx.xxx
www.mydomain.com.ar/2 --> App 2 at xxx.xxx.xxx.xxx
Etc
I read some posts here and some other articles online, but I have two issues
- I Can’t get the proxy redirection working
- When I get it working i get the awfull xojo text message “The app is offline”
Here’s the ngix.conf in case anyone can help… It’s based on what’s been said on this post.
The domain I was using for testing purposes is not online now)
[code]worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 64;
#You can change the log format if you want with something like this
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
#This is for load balancing. See below for different proxy_pass directive.
#If you wanted to load balance multiple different apps you would need more upstream
# directives with different names pointing to different ports for that group of apps.
#This essentially gives a logical name to a group of server directives and attempts
# to distribute the load among the group.
#Disabled for now.
#upstream YourLogicalAppName {
# ip_hash; #Needed for session persistence.
# My limited testing for ip_hash shows this may not result in evenly
# distributing the load among the different instances but Xojo must
# have session persistence.
# server 127.0.0.1:<XojoAppONEport1>; #Instance One
# server 127.0.0.1:<XojoAppONEport2>; #Instance Two
#} #End Upstream
#----------------------------------------
#Normally you would do this return directive to force HTTP to HTTPS using variables ... but ...
# return 301 https://$server_name$request_uri;
#I had trouble with this format when I had multiple domains resolving to the same IP.
#My solution was to just "Hard Code" the return URL but other formats may work.
#----------------------
#This forces http to https for domain 1
#Browser cache can cause problems with 301 redirects.
#Read here for more:
#http://stackoverflow.com/questions/9130422/how-long-do-browsers-cache-http-301s#21396547
server {
listen 80;
server_name guestreport.com.ar;
return 301 https://guestreport.com.ar;
} #End Server
#----------------------
server {
server_name guestreport.com.ar;
listen 443 ssl;
#You can put your certs anywhere you want.
#Note that in the bundle your site specific cert should be
# ADDED IN FRONT of the other intermediate certs if needed.
#The server key should not have a password if you intend to run
# NGINX as a Windows service with NSSM.
# With a password you will be prompted when NGINX launches.
#The password can be removed with OPENSSL. Be careful not to expose the key file.
ssl_certificate guestreport.crt;
ssl_certificate_key guestreport_com_ar_key;
location /main {
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-Proto https;
# proxy_set_header X-Forwarded-For $remote_addr;
# proxy_set_header X-Forwarded-Host $remote_addr;
# proxy_buffering off;
# proxy_cache off;
# proxy_pass http://66.97.40.251:5941;
root html;
#If you enable load balancing (upstream) above use this instead
#proxy_pass http:YourLogicalAppName; #For load balancing
} # End Location
location = /test1 {
return 302 /test1/;
}
location /test1 {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_buffering off;
proxy_cache off;
proxy_pass http://66.97.40.251:5941/;
}
} #End Server
#----------------------
} #end http[/code]