0

geth --testnet --networkid 3 --syncmode "fast" --datadir "." --cache=2048 --rpc --rpcport 8545 --rpcaddr example.ropsten.hk --rpcvhosts example.ropsten.hk --rpccorsdomain "*" --rpcapi="web3,miner,admin,db,net,eth,personal,debug,txpool"

I am able to connect with to the geth client using IP address and port, If i am mentioning domain name it is throwing invalid json rpc response

const Web3 = require('web3')

let web3 = new Web3(new Web3.providers.HttpProvider('https://user:pwd@example.ropsten.hk')) here is my nginx config file, server {

listen 443 ssl;
server_name example.ropsten.hk;

ssl_certificate /etc/ssl/certs/certificate.crt;
ssl_certificate_key /etc/ssl/certs/private.key;

ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-SEED-SHA:DHE-RSA-CAMELLIA128-SHA:HIGH:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS';
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
server_tokens off;
proxy_set_header X-Forward-For $remote_addr;

#log
access_log /var/log/nginx/ropsten.access.log;
error_log /var/log/nginx/ropsten.error.log;

location / {
    # Enabling Cors
    if ($request_method ~* "(GET|POST|PATCH|PUT|DELETE)") {
        add_header "Access-Control-Allow-Origin"  *;
        add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
        add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
    }

    # Preflighted requests
    if ($request_method = OPTIONS ) {
        add_header "Access-Control-Allow-Origin"  *;
        add_header "Access-Control-Allow-Methods" "GET, POST, PATCH, PUT, DELETE, OPTIONS, HEAD";
        add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
        return 204;
    }
    auth_basic    "Ethereum protected client";
    auth_basic_user_file /etc/nginx/.htpasswd;
    proxy_pass http://example.ropsten.hk:8545;
    proxy_http_version 1.1;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded_Host $server_name;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    }   

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.