setting up subdomain in url locally - ruby-on-rails

I am creating a rails application where we have functionality for registering a new User is there and there we are providing separate sub domain for each user by their user name.
so i want to map
user_name.localhost:3000.com where user_name is dynamic

Run your local development server with pow. If you symlink the app to the foo, than your pages are available under http://foo.dev, but also under every other subdomain like http://bar.foo.dev. There is no need to register a list of subdomains somewhere.
prax might be an alternative when you are on linux.

Access like this. No configuration required
user_name.lvh.me:3000

I have figured it out.
Actually the application is using subdomain_fu gem for creation of the subdomain and when the user is created the subdomain is name is saved in the db and the can accessed by making configuration into the file C:\Windows\System32\drivers\etc\hosts and map the ip which is being hit like ;
192.xxx.xx.xxx user_name.your_subdomain _name
and hit the url like this ;
user_name.your_subdomain _name:3000
It is working fine with me doing these steps.
Thanks to all for their valuable feed back.

Related

Change the domain mautic uses when generating the urls (previews, emails, landing pages)

I have a docker instance of mautic and it works like a charm.
The only issue is that
the urls generated inside emails (eg. Unsubscribe URL)
the preview links of the forms/emails
the landing page urls
are all pointing to the wrong domain name (network IP address of the guest machine)
I'd like to change that to the url of my mautic installation.
I've checked out the settings with no luck and also looked at all the files inside app/config directory.
Can't be sure about doing inside docker, but in the past we have been using reverse proxy and pointing it to the docker instance, also this helped us using more than one instance along with setting up ssl certificate as well. here's one setup example:
https://github.com/stollz/MauticSSLDocker
hope this helps.

How can I point Freenom domain to a Heroku app?

I want to link my domain to my Heroku rails app.
What steps should I follow? What should I enter in the following Freenom form?
You can create a CNAME record like so:
Name Type TTL Target
www CNAME 14440 appname.herokuapp.com
You might need to setup something different to forward apex to www to that http://yourdomain.com forwards to http://www.yourdomain.com

Setting up a custom domain with Heroku and namecheap

I've followed all the instructions on https://devcenter.heroku.com/articles/custom-domains to get my custom domain set up, and it still isn't working.
On Heroku, I have the following domains:
myapp.herokuapp.com
example.com
www.example.com
And on Namecheap, I have the following settings:
HOST NAME | IP ADDRESS/URL | RECORD TYPE
# http://example.com URL Redirect
www myapp.herokuapp.com. CNAME(Alias)
When I run: "host www.example.com" in my terminal, I expect to get "www.example.com is an alias for myapp.herokuapp.com". Instead, I get:
"www.example.com is an alias for myapp.heroku.com"
I can't figure out why it is pointing to myapp.heroku.com, because I have only specified myapp.herokuapps.com.
Does anybody know why this is happening?
Update note: Heroku and Namecheap change their interfaces every so often. This answer may have outdated screenshots, but it will be updated over time. See these updates below.
I've just done this myself so I thought I'd chime in as the answer doesn't illustrate how to get both www.example.org and example.org working. Heroku also changed its admin interface a bit.
Namecheap
First, login to Namecheap.
Go to Domain List and click "Manage" for the domain you're configuring.
Set both record types to CNAME (Alias) and enter your <name>.herokuapp.com in both url-boxes (# and www).
(PS: If they're not there, click the "Add new record" and add them there.)
Next, head over to Heroku
Login and choose your project from the list. For this example, we're choosing the "Lakka" project.
On the project page, click Settings
Scroll down and find the Add domain section
Enter your example.org and click Save.
Click the button again, and input your www.example.org and click Save.
That's it, You're done! Now when you enter example.org or www.example.org in your browser, both will show your Heroku project.
In this example, http://lakka.herokuapp.com would be accessible (after DNSes update) also on http://lakkatracker.com and http://www.lakkatracker.com.
(If you want to redirect traffic from www.example.org to example.org, which is a good practise, you can use the record type "URL (Redirect)" for the www host name)
It can take some time before your DNSs recognize the changes. You can try using a proxy for testing, like Anonymouse, if your changes aren't reflected immediately.
1) Go To Namecheap, and go to the domain you want to manage.
2) On the left sidebar, click "All Record Hosts", NOT any of the other jazz other tutorials tell you. No DNS pointing changes are necessary. It's easier to use alias.
3) Once you do, you'll see a line starting with "www" as a CNAME (Alias) option. Fill this in as your heroku app's domain name example.herokuapp.com
That's it for namecheap.
4) Then at heroku settings, under "domains", enter your purchased domain name you wish to be displayed.
That's it!
It's as easy as letting heroku and namecheap know about both domain aliases.
Credits to this blog:
http://blog.romansanchez.me/2013/06/08/point-namecheap-domain-to-heroku/
Update:
Apparently, heroku will only allow sites with www. prepended. To have a true root domain without www. will take some extra ninja hacking.
Namecheap updated its interface. New screenshots to supplement other good answers:
If you want all the traffic to point to http://example.com then do this:
and set both example.com and www.example.com in Heroku settings.
Then test everything by using http://anonymouse.org
Set up a namecheap config that looks like this:
And a heroku config that looks like this:
And you're good to go!
Depending on your application, it may be a result of not using an SSL certificate. If you are trying to use an SNI SSL on the free dyno it is not going to work. In my case, I upgraded to hobby dyno and it immediately worked via the ACM.
Here are 2 possibilities,
You had previously pointed the DNS records to myapp.heroku.com and the changes haven't propagated yet
This could be an artifact of the change Heroku made move apps from the heroku.com domain to the herokuapp.com domain, but I'm unsure of how this could happen or why it would happen for you; records for my apps all point directly to herokuapp.com, but I'm not using NameCheap.
You could try registering a different (free) domain with an entity like .tk to see if this is specific to NameCheap.
I linked a namecheap domain to my Heroku app today and it is now a bit different, so here is what I did.
Add the domain (purchased on namecheap) to your Heroku app like www.example.com. The 'www' is important. Copy the generated xxx.herokudns.com link.
Now go to your domain settings on namecheap. Click on Advanced DNS.
Add the following two records:
Type: CNAME Record, Host: www, Value: the copied URL from step 1.
Type: URL Redirect Record, Host: #, Value: http://www.example.com
Save and maybe you have to wait for up to 30 minutes.
I couldn't get both www.example.com and example.com to work, so one of the workarounds I found was to set the CNAME and # to www., and then on the Domain tab, set "Redirect Doman" from example.com to www.example.com.

Pointoing my Heroku Rails app to www and without www works only for an hour?

My Rails app works with Heroku and if I set my CNAME at my domain register Afrihost to www.domain and without the www it works fine for an hour. Then it kills the app without the www domain infront and I have to log in and change the dns again.
Afrihosts states, because of a certain law it can't point a cname to both with a www and without a www in-front. Is that true for all domain registers?
What alternatives are there as I want to point to both with and without the www in-front.
Thanks in advance.
Erin
I liked the fix I went with. I just added a url redirect from mywebsite.com to www.mywebsite.com. So on type you just choose 'Redirect' and leave the host part blank. Then type in the url of your website 'http://www.mywebsite.com/' in the 'Data' section. Worked for me.
CNAMES cannot be used on naked domains (e.g. yourapp.com), only subdomains (e.g www.yourapp.com).
For the naked domains, you need an A record, or something like DNSimple's ALIAS.
I found the answer https://devcenter.heroku.com/articles/avoiding-naked-domains-dns-arecords
I must use an A-Record.
Thanks

Make local development work with Facebook/Google APIs

I'm working on implementing omniauth into a Rails project. My problem is that the authentication providers - Twitter, Google, Facebook etc all require me to create an application with a url that limits authentication requests from anywhere other than the url. I need to be able to to test locally but also run code in production, but Facebook for example doesn't allow 2 domains and doesn't allow localhost anyhow.
So what are my options?
At work, we have multiple applications setup for the different environments. On local, add an entry in /etc/hosts (assuming you are on linux) eg: 127.0.0.1 mydomain.local.
On the facebook app setup for the local environment, add this as the url. Most things, except where facebook needs to scrape your site (Like buttons) work.
Here's a blog post with my solution: http://make.bettermistak.es/2012/05/03/how-to-create-a-local-sandbox-facebook-app/
Here's the relevant bit: "Facebook verifies that all requests for your app are coming from the right domain–they don’t allow requests from localhost or 127.0.0.1–and this info can be updated in your apps settings under Hosting URL. Add “local.herokuapp.com” to your Hosting URLs and save this setting. Then edit your /etc/hosts file so that local content is under the domain local.herokuapp.com. This file is hidden, so from the command line enter sudo vi /etc/hosts. (Substitute your favorite editor for vi.) We need to use sudo, because this file is locked. Add the line “127.0.0.1 local.herokuapp.com” below “127.0.0.1 localhost” and save and quit your text editor."
As far as I know, you must sing up two apps for you app.(one for remote side, one for local side)
Fortunately, there is a way to reduce the complication(Assuming you are working on linux):
You can configure you .bash_profile (local machine and remote machine separately):
export YOURAPP_APP_ID="XXXXX"
export YOURAPP_APP_SECRET="XXXXX"
And use ENV['YOURAPP_APP_ID'] and ENV['YOURAPP_APP_SECRET'] in your code.
For example, you can code like this in rails:
config.omniauth :facebook, ENV['YOURAPP_APP_ID'], ENV['YOURAPP_APP_SECRET']
By this way, you can use the same code in both local and remote side. It will be much easier for maintaining.
If you are using Heroku to host your application, you can refer to this page to config the environment variables.
I have created two apps on Facebook one of which i run in sandbox mode for development purposes. Would that be an option for you?

Resources