I was implementing https://layer.com/ on https://zeemee.com and they require https for the callbacks. Since this was new to me and took me a while here's a how to if anyone is looking.
You already have a rails app running on localhost:3000
You're going to need to get a static IP address for your computer. My ISP is https://sonic.net. They give you one free static IP with your account. In any case - you'll need an IP address and you'll need to configure it.
If you're also on Sonic this is how:
Test it If you've done everything right you should be able to now hit your Rails app at http://your-ip-address:3000
Does your wifi router have a firewall? Mine does. I had to open up ports on my home wifi router. You'll want to open port 80, 443 and 3000. Most wifi routers are available at http://192.168.42.1/
Also - is your Mac's Firewall running? You can turn it off at System Preferences > Security & Privacy > Firewall
Simple - just go to some place like https://www.namecheap.com/ and register a domain name.
You'll then need to add 2 A records. On Namecheap this is pretty simple. You need to add @
and www
that both point to your IP. Remove any A records pointing at placeholders.
Test it If you've done everything right you should be able to hit your app at http://your-domain:3000
I used Homebrew to setup NGINX. It's easy peasy:
brew install NGINX
sudo nginx
Test it You should now be able to go to http://localhost:8080 and see a welcome to NGINX message
vim /usr/local/etc/nginx/nginx.conf
Find
server {
listen 8080;
And change 8080 to 80
Test it
sudo nginx -s stop
sudo nginx
You should now be able to see the NGINX welcome message by going to http://localhost
vim /usr/local/etc/nginx/nginx.conf
Change location to:
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Test it
sudo nginx -s stop
sudo nginx
You should now see you Rails app when you hit http://localhost
This stuff is pretty confusing and a bitch to debug but, this is how I got it working.
You'll need to setup email on your new domain. On Namecheap this is pretty trivial. Add either a wildcard or a [email protected]
. https://www.namecheap.com/support/knowledgebase/article.aspx/308/76/how-can-i-set-up-free-email-forwarding-for-my-domain. Make sure this works... you'll need to be able to get email at [email protected]
This is cheap ($10). Again - I used Namecheap to get this https://www.namecheap.com/security/ssl-certificates.aspx
When you go to setup your HTTPS cert they're going to ask you for a CSR. You can generate this on your Mac in terminal:
openssl x509 -req -days 365 -in domain.csr -signkey domain.key -out domain.crt
Replace domain
with your domain name (not required, just easier)
I like to keep all this ssl nonsense in ~/.ssl
but, it doesn't really matter.
Make sure, when asked for 'Common Name' that you enter your new domain (my-domain.com)
The your-domain.csr
contents is what you'll need when you setup your HTTPS cert.
Once you've done that you'll recieve a verification email from the cert provider. And, after verifying, they'll send you a cert. Mine had a zip file which I extracted into ~/.ssl
vim /usr/local/etc/nginx/nginx.conf
Add another server in NGINX (should be commented out already) and change location to something like this:
# HTTPS server
#
server {
listen 443 ssl;
server_name wiseleyb.com;
ssl_certificate /Users/wiseleyb/.ssl/wiseleyb_com/wiseleyb_com.crt;
ssl_certificate_key /Users/wiseleyb/.ssl/wiseleyb.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Test it
sudo nginx -s stop
sudo nginx
You should now be able to go to https://your-domain.com and see you app!