Difference between revisions of "Bitcoin-js-remote"

From Bitcoin Wiki
Jump to: navigation, search
(Apache HTTPD Configuration for Bitcoin JS Remote)
 
(13 intermediate revisions by 3 users not shown)
Line 10: Line 10:
 
* [http://github.com/tcatm/bitcoin-js-remote Bitcoin-js-remote] project page
 
* [http://github.com/tcatm/bitcoin-js-remote Bitcoin-js-remote] project page
  
==Apache HTTPD Configuration for Bitcoin JS Remote==
+
 
[I am assuming a little knowledge about Apache httpd. You had better read on Apache httpd directives: http://httpd.apache.org/docs/2.2/mod/directives.html]
+
==Example of an Apache HTTPD Configuration for Bitcoin JS Remote==
 +
[I am assuming a little knowledge about Apache httpd. You had better read on Apache httpd directives: http://httpd.apache.org/docs/2.2/mod/directives.html. Of course, this is only an example of many other configurations]
  
 
Assuming your bitcoin.conf file includes:
 
Assuming your bitcoin.conf file includes:
 
+
  rpcuser=myuser
rpcuser=myuser
+
  rpcpassword=mypass
rpcpassword=mypass
 
  
 
First, generate a suitable file for Basic Authentification. See man htpasswd or execute
 
First, generate a suitable file for Basic Authentification. See man htpasswd or execute
Line 22: Line 22:
  
 
Set following Apache directives in the proper context, i.e. server or virtual host configuration:
 
Set following Apache directives in the proper context, i.e. server or virtual host configuration:
 +
  <Proxy http://127.0.0.1:8332>
 +
    AuthType Basic
 +
    AuthName "Bitcoin Access"
 +
    AuthUserFile my_prefer_filename
 +
    Require user myuser
 +
    Order deny,allow
 +
    Allow from all
 +
  </Proxy>
 +
 +
Assuming you want to access Bitcoin JS Remote with http://mydomain/jbc
 +
  Alias /jbc pathabs_to_bitcoin-js-remote
 +
  ProxyPass /lbc/ http://127.0.0.1:8332/
 +
  # ProxyPassReverse is not required because bitcoind talks pure
 +
  # JSON, i.e no HTTP Headers with URIs are generated by bitcoind
 +
  # ProxyPassReverse /lbc/ http://127.0.0.1:8332/
  
<Proxy http://127.0.0.1:8332>
+
Above ProxyPass directive is asuming you are set the RPC.url field to "/lbc/" into "settings.json" file, located in the bitcoin-js-remote directory. See the settings.json_sample file for proper syntax.
  AuthType Basic
 
  AuthName "Bitcoin Access"
 
  AuthUserFile my_prefer_filename
 
  Require user myuser
 
  Order deny,allow
 
  Allow from all
 
</Proxy>
 
  
# Assuming you want to access Bitcoin JS Remote with http://mydomain/jbc
+
A variety of configurations are feasible:
  Alias /jbc pathabs_to_bitcoin-js-remote
+
 
 +
  # If RPC.url is an absolute path (i.e. RPC.url : /lbc/),
 +
  # bitcoind at 127.0.0.1 shall be accessed by http://mydomain/jbc/
 
   ProxyPass /lbc/ http://127.0.0.1:8332/
 
   ProxyPass /lbc/ http://127.0.0.1:8332/
   ProxyPassReverse /lbc/ http://127.0.0.1:8332/
+
   #
 +
  # If RPC.url is a relative path (i.e. RPC.url : lbc/),
 +
  # bitcoind at 127.0.0.1 shall be accessed by http://mydomain/jbc/lbc/
 +
  ProxyPass lbc/ http://127.0.0.1:8332/
 +
  #
 +
  # Apache can also proxy your access to any other IP by
 +
  # accessing to http://mydomain/jbc
 +
  ProxyPass /lbc/ http://www.worldbank.org:8332/
  
User and Password will be required when accessing with http://mydomain/jbc. Then, set Bitcoind's URL to the desired path: in the above example will be “/lbc/” or by default will be “/”.
+
Please, note you are *not* required to set into the settings.json file the pair rcpuser/rcppassword. The required header with Basic Authentication is automatically generated by Apache when proxing, thanks for the above Auth directives.
  
Alternatively, create a “settings.json” file in the bitcoin-js-remote directory: (see proper syntax in the settings.json_sample):
+
Set RPC.user=rcpuser and RPC.password=rcppassword in the settings.json file if you are not able to configure your Apache webser; for instance, people using hosting instead of virtual or dedicated server. But, please, '''keep in mind''' settings.json file can be read by everybody: http://mydomain/jbc/settings.json
  RPC.url : /lbc/
 
  RPC.user : myuser
 
  RPC.password : mypass
 
  
 
That's all. Restart your Apache web server.
 
That's all. Restart your Apache web server.
  
Other interesting Apache directives:
+
=== Other interesting Apache directives: ===
 +
 
 
To redirect all HTTP to HTTPS (of course, you need a well-configured ssl site).
 
To redirect all HTTP to HTTPS (of course, you need a well-configured ssl site).
!!! SSL access is extremely recommended to protect your Bitcoin data.
+
!!! SSL access '''is extremely recommended''' to protect your Bitcoin data.
 
+
  RewriteCond %{HTTPS} off
RewriteCond %{HTTPS} off
+
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
 
  
 
To avoid your log file from flooding
 
To avoid your log file from flooding
 
+
  SetEnvIf Request_URI "^/jbc/" dontlog
SetEnvIf Request_URI "^/jbc/" dontlog
+
  SetEnvIf Request_URI "^/lbc/" dontlog
SetEnvIf Request_URI "^/lbc/" dontlog
+
  CustomLog myfile.log combined env=!dontlog
CustomLog myfile.log combined env=!dontlog
 
  
 
Finally, if you go in trouble, check proper access to bitcoin daemon with curl:
 
Finally, if you go in trouble, check proper access to bitcoin daemon with curl:
 +
  curl --trace-time --trace-ascii - \
 +
      --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' \
 +
      --header 'content-type: text/plain;'\
 +
      http://myuser:mypass@127.0.0.1:8332/
  
curl --trace-time --trace-ascii - --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' --header 'content-type: text/plain;' http://myuser:mypass@127.0.0.1:8332/
+
[[Category:User Interfaces]]
 
+
[[Category:Frontends]]
[[Category:Clients]]
 
 
[[Category:Free Software]]
 
[[Category:Free Software]]
 
[[Category:License/MIT-X11]]
 
[[Category:License/MIT-X11]]
 
[[Category:Open Source]]
 
[[Category:Open Source]]
 +
[[Category:Mobile]]

Latest revision as of 16:47, 25 June 2011

A user interface for Bitcoin written in JavaScript.

For SSL support a small server side script is included.

This software is released under the MIT/X11 License.

External Links


Example of an Apache HTTPD Configuration for Bitcoin JS Remote

[I am assuming a little knowledge about Apache httpd. You had better read on Apache httpd directives: http://httpd.apache.org/docs/2.2/mod/directives.html. Of course, this is only an example of many other configurations]

Assuming your bitcoin.conf file includes:

 rpcuser=myuser
 rpcpassword=mypass

First, generate a suitable file for Basic Authentification. See man htpasswd or execute

 htpasswd -b -c my_prefer_filename myuser mypass

Set following Apache directives in the proper context, i.e. server or virtual host configuration:

 <Proxy http://127.0.0.1:8332>
   AuthType Basic
   AuthName "Bitcoin Access"
   AuthUserFile my_prefer_filename
   Require user myuser
   Order deny,allow
   Allow from all
 </Proxy>

Assuming you want to access Bitcoin JS Remote with http://mydomain/jbc

 Alias /jbc pathabs_to_bitcoin-js-remote
 ProxyPass /lbc/ http://127.0.0.1:8332/
 # ProxyPassReverse is not required because bitcoind talks pure
 # JSON, i.e no HTTP Headers with URIs are generated by bitcoind
 # ProxyPassReverse /lbc/ http://127.0.0.1:8332/

Above ProxyPass directive is asuming you are set the RPC.url field to "/lbc/" into "settings.json" file, located in the bitcoin-js-remote directory. See the settings.json_sample file for proper syntax.

A variety of configurations are feasible:

 # If RPC.url is an absolute path (i.e. RPC.url : /lbc/),
 # bitcoind at 127.0.0.1 shall be accessed by http://mydomain/jbc/
 ProxyPass /lbc/ http://127.0.0.1:8332/
 #
 # If RPC.url is a relative path (i.e. RPC.url : lbc/),
 # bitcoind at 127.0.0.1 shall be accessed by http://mydomain/jbc/lbc/
 ProxyPass lbc/ http://127.0.0.1:8332/
 # 
 # Apache can also proxy your access to any other IP by
 # accessing to http://mydomain/jbc
 ProxyPass /lbc/ http://www.worldbank.org:8332/

Please, note you are *not* required to set into the settings.json file the pair rcpuser/rcppassword. The required header with Basic Authentication is automatically generated by Apache when proxing, thanks for the above Auth directives.

Set RPC.user=rcpuser and RPC.password=rcppassword in the settings.json file if you are not able to configure your Apache webser; for instance, people using hosting instead of virtual or dedicated server. But, please, keep in mind settings.json file can be read by everybody: http://mydomain/jbc/settings.json

That's all. Restart your Apache web server.

Other interesting Apache directives:

To redirect all HTTP to HTTPS (of course, you need a well-configured ssl site). !!! SSL access is extremely recommended to protect your Bitcoin data.

 RewriteCond %{HTTPS} off
 RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

To avoid your log file from flooding

 SetEnvIf Request_URI "^/jbc/" dontlog
 SetEnvIf Request_URI "^/lbc/" dontlog
 CustomLog myfile.log combined env=!dontlog

Finally, if you go in trouble, check proper access to bitcoin daemon with curl:

 curl --trace-time --trace-ascii - \
      --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' \
      --header 'content-type: text/plain;'\
      http://myuser:mypass@127.0.0.1:8332/