Renaming site1.local to domain.com issue

Hi,

When I rename site1.local to “domain.com”, website opens at “domain.com” but not at “www.domain.com”. And registration email is also not getting sent. Pls advice how to get rid of this.

Just to give few background picture:

  1. domain.com is re-directed to www.domain.com at godaddy.
  2. I have regenerated the nginx config.

You have to set a separate CNAME RECORD for www.domain.com that points to domain.com

Thank you Rushabh,
CNAME RECORD Is there but site is not serving. In fact, I renamed site1.local as “domain.com” and pointed “www” to “@” i.e “domain.com” but then also no luck.

I’m unable to figure out where I’m making mistake. Pls suggest some options.

Sunil
Nescode (http://nescode.com)
Partner for ERPNext

Sorry you have to symlink your site for each domain you are serving. (each domain should map to a folder in frappe-bench/sites

Hello Rushabh,
I’m adding

"host_name":"http://nescode.org"

in sites > nescode.org > site_config.json. But getting following error while re-generating nginx config file

sunil_kumar_nescode_com@nescode-foundation:~/frappe-bench$ cd sites
sunil_kumar_nescode_com@nescode-foundation:~/frappe-bench/sites$ cd nescode.org
sunil_kumar_nescode_com@nescode-foundation:~/frappe-bench/sites/nescode.org$ vi site_config.json
sunil_kumar_nescode_com@nescode-foundation:~/frappe-bench/sites/nescode.org$ cd ..
sunil_kumar_nescode_com@nescode-foundation:~/frappe-bench/sites$ cd ..
sunil_kumar_nescode_com@nescode-foundation:~/frappe-bench$ bench setup nginx
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==0.1', 'console_scripts', 'bench')()
  File "/home/sunil_kumar_nescode_com/bench-repo/bench/cli.py", line 29, in cli
    return bench()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/home/sunil_kumar_nescode_com/bench-repo/bench/cli.py", line 220, in setup_nginx
    generate_nginx_config()
  File "/home/sunil_kumar_nescode_com/bench-repo/bench/config.py", line 41, in generate_nginx_config
    sites = get_sites_with_config(bench=bench)
  File "/home/sunil_kumar_nescode_com/bench-repo/bench/config.py", line 35, in get_sites_with_config
    } for site in sites]
  File "/home/sunil_kumar_nescode_com/bench-repo/bench/config.py", line 28, in get_site_config
    return json.load(f)
  File "/usr/lib/python2.7/json/__init__.py", line 278, in load
{
    **kw)
  File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 381, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting , delimiter: line 4 column 2 (char 66)

Even I tried with below but again it gives error while re-generating nginx config file

"host_name": "http"//nescode.org",

Hello Rushabh,

Sorry, when I entered host name in sites > config.json it working now.

"host_name": "http"//nescode.org"

Thank you so much for your guidance.

Sunil

Hello Rushabh,

Portal was opening because of browser cache. :smile:
I’m modifying site_config.json and adding

 "host_name": "http://nescode.org" 

But it gives error on

bench setup nginx

Sunil

Did you create a synlink in your sites dir?

Pls correct me, if I’m making mistake. This is how I’m doing symlink after modifying site_config.json. It gives an error

sunil_kumar_nescode_com@nescode-foundation:~$ ln -s /etc/nginx/sites-available/default.conf /frappe-bench/sites/nescode.org/site_config.json
ln: failed to create symbolic link `/frappe-bench/sites/nescode.org/site_config.json': No such file or directory

I have modified default.conf in /etc/nginx/sites-available/default

server_name .nescode.org

Sunil

Something like this:

ln -s sites/mysite.com sites/www.mysite.com

Why don’t you just setup a redirect? ie. www.domain.com to domain.com

All leading DNS hosting providers allow you to setup a “URL Redirect”

We do the same,

 % curl -I www.frappecloud.com
HTTP/1.1 307 Temporary Redirect
Server: nginx
Date: Wed, 22 Oct 2014 08:00:56 GMT
Content-Type: text/html
Content-Length: 180
Connection: keep-alive
Location: https://frappecloud.com/

Hello Pratik,

I checked by URL redirect, its not working, will configure symlink as you and rushabh suggested.

Sunil

Hello Pratik,

Renamed site1.local to www.domain.com and did the symlink and domain forwarding (domain.com to www.domain.com) but still site is not opening at “domain.com”. However it opens at www.domain.com

Now i need your expertise seriously :smile:

Sunil

What are the DNS rules you have set?

Hello Rushabh,

DNS rules I have set in default.conf inside /etc/nginx/sites-available is:

server {
     listen  80;       
     server_name domain.org;       
     return 301 http://www.domain.org$request_uri;
}

Let me brief the steps which i used to reach here:

Step1: Renamed “site1.local” to “www.domain.org” inside /frappe-bench/sites/ followed by few necessary command.

bench config dns_multitenant on
mv site1.local www.domain.org
bench setup nginx
sudo service nginx reload

Step2: Modified default.conf inside /etc/nginx/sites-available:

server {
     listen  80;       
     server_name domain.org;       
     return 301 http://www.domain.org$request_uri;
}

(Step 2 is i think same steps as domain forwarding at Godaddy. )

Step3: Symlink from frappe-bench directory

ln -s sites/domain.org sites/www.domain.org

After step1, even I tried to modify sites_config.json inside frappe-bench/sites/www.domain.org with below changes but it gives error when I run “bench setup nginx”

{
 "db_name": "site1.local",
 "db_password": "************"
 "host_name": "http://www.domain.org"
}

This might be because I’m not passing any parameter for “host_name”: “http://www.domain.org

– If you can help me how to configure site_config.json for custom domain, it would be a great help.

My objective behind this excercise:

  1. When someone register/communicate at www.domain.org, account activation/communication mail link goes with “http://site1.local…” therefore users are unable to complete the registration process and other such activities.
    User should get right link when any communication goes out of system.

I think I’m not performing the steps correctly. If you can help with the steps and configuration, It would be great help.

Sunil

1 Like

Just adding host_name to site_config should clear your objective.

When I add (“host_name”: “http://domain.org”) to site_config.json inside /frappe-bench/sites/www.domain.org like below,

{
 "db_name": "site1.local",
 "db_password": "***********"
 "host_name": "http://domain.org"
}

It gives an error when I run “bench setup nginx”.

sunil_kumar_nescode_com@nescode-foundation:~/frappe-bench$ bench setup nginx
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==0.1', 'console_scripts', 'bench')()
  File "/home/sunil_kumar_nescode_com/bench-repo/bench/cli.py", line 29, in cli
    return bench()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/home/sunil_kumar_nescode_com/bench-repo/bench/cli.py", line 220, in setup_nginx
    generate_nginx_config()
  File "/home/sunil_kumar_nescode_com/bench-repo/bench/config.py", line 41, in generate_nginx_config
    sites = get_sites_with_config(bench=bench)
  File "/home/sunil_kumar_nescode_com/bench-repo/bench/config.py", line 35, in get_sites_with_config
    } for site in sites]
  File "/home/sunil_kumar_nescode_com/bench-repo/bench/config.py", line 28, in get_site_config
    return json.load(f)
  File "/usr/lib/python2.7/json/__init__.py", line 278, in load
    **kw)
  File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 381, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting , delimiter: line 4 column 2 (char 66)
sunil_kumar_nescode_com@nescode-foundation:~/frappe-bench$ 

Pls suggest the right parameter and value for site_config.json.

Sunil

your JSON must be invalid. Paste it (the site_config.json) here and see http://jsonlint.com/

Yes, it gives error while validating. Pls suggest, what should be the content of site_config.json?

Sunil