Author: Avi D' Silva
The current ScottyPro Ticketer runs on an AWS instance, and it was being pointed to using an Iframe.
This entry documents all the changes that were done to move away from the Iframe approach and use the DNS directly. This can also be referred when configuring a new instance with ScottyPro-Ticketer.
The Ticketer instance itself runs on “:8083/Ticketer” so the first thing that needs to be done:
Install Nginx as a proxy (sudo apt-get install nginx)
You will find the configuration in /etc/nginx/conf/sites-enabled
Now we have to configure nginx to handle the following use cases:
1. Proxy traffic from Port 80 to Port 8083 2. Forward all http://www.scottypro.com requests to http://scottypro.com 3. Redirect all base URL requests to Ticketer App (Ex: http://scottypro.com/?tid=100 becomes http://scottypro.com/Ticketer/?tid=100) 4. Edge case where Ticketer adds an extra slash "*.com//auth/signin" 5. Edge case where Ticketer adds an extra slash on logout "*.com//"
First we create a file “/etc/nginx/sites-enabled/www-scotty-to-non-www” This will basically convert any www traffic to non-www
server {
server_name www.scottypro.com;
return 301 $scheme://scottypro.com$request_uri;
}
Next, we create/edit the file “/etc/nginx/sites-enabled/default” The rules are written to take care of rest of the above use cases.
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.html index.htm;
# Make site accessible from http://scottypro.com/
server_name scottypro.com;
merge_slashes off;
rewrite ^(.*?)//+(.*?)$ $1/Ticketer/$2 permanent;
location /Ticketer {
proxy_pass http://localhost:8083/Ticketer;
}
location / {
rewrite ^/(.*)$ http://scottypro.com/Ticketer/$1 redirect;
}
location // {
rewrite ^/(.*)$ http://scottypro.com/Ticketer/$1 redirect;
}
}
The last thing that remains would be point the A record of scottypro.com (from godaddy.com) to point to the right IP address
Also, add a CNAME record for “www” to point the base “*” or “@” record. so that both www and non-www point to the same IP.