I need to access non-SSL APIs running on the same host as my nginx webserver from my SSL website. This is currently being done via proxy connections by including location blocks such as below in the conf file for my site
server {
listen 443 ssl;
server_name localhost;
root /websites/MineETN.today/html;
index index.html;
ssl on;
ssl_certificate /home/dwayne/certs/mineetn_today.chained.crt;
ssl_certificate_key /home/dwayne/certs/mineetn_today.key;
location /json_rpc {
proxy_pass http://127.0.0.1:26968/json_rpc;
}
location ~ ^/api/(.*) {
proxy_pass http://127.0.0.1:8117/$1$is_args$args;
}
}
This works fine when Cloudflare is paused, but breaks when Cloudflare is enabled.
WIthout Cloudflare
184.175.45.136 - - [11/Mar/2018:22:00:30 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36" "-"
184.175.45.136 - - [11/Mar/2018:22:00:31 +0000] "GET /api/stats HTTP/1.1" 200 439 "https://mineetn.today/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36" "-"
184.175.45.136 - - [11/Mar/2018:22:00:31 +0000] "GET /pages/home.html?_=1520805627711 HTTP/1.1" 200 12069 "https://mineetn.today/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36" "-"
184.175.45.136 - - [11/Mar/2018:22:00:33 +0000] "GET /api/live_stats HTTP/1.1" 200 450 "https://mineetn.today/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36" "-"
184.175.45.136 - - [11/Mar/2018:22:00:36 +0000] "GET /api/live_stats HTTP/1.1" 200 450 "https://mineetn.today/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36" "-"
184.175.45.136 - - [11/Mar/2018:22:00:39 +0000] "GET /api/live_stats HTTP/1.1" 200 450 "https://mineetn.today/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36" "-"
etc as page is refreshing every 3 seconds
https://mineetn.today/api/stats returns:
{“config”:{“ports”:[{“port”:3333,“difficulty”:100,“desc”:“Low end hardware”},{“port”:5555,“difficulty”:2000,“desc”:“Mid range hardware”},{“port”:7777,“difficulty”:10000,“desc”:“High end hardware”}],“hashrateWindow”:600,“fee”:0,“coin”:“electroneum”,“symbol”:“ETN”,“depth”:20,“donation”:0,“coreDonation”:0,“doDonations”:false,“version”:“v0.99.3.3”,“minPaymentThreshold”:500,“denominationUnit”:100,“slushMiningEnabled”:false,“weight”:300},“pool”:{“stats”:null,“blocks”:,“totalBlocks”:0,“payments”:,“totalPayments”:0,“totalMinersPaid”:-1,“miners”:1,“hashrate”:2722.5833333333335,“roundHashes”:365610086},“network”:{“difficulty”:19111320831,“height”:193140,“timestamp”:1520817743,“reward”:667454,“hash”:“8cd75b7de21fa27e52dfc7cf6380c4de9f575692fed12eaa83d76790dbf36954”}}
WITH Cloudflare
108.162.241.86 - - [12/Mar/2018:01:00:56 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36" "184.175.45.136"
108.162.241.86 - - [12/Mar/2018:01:01:01 +0000] "GET /api/stats HTTP/1.1" 200 436 "https://mineetn.today/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36" "184.175.45.136"
https://mineetn.today/api/stats returns:
mRM�� �+ќ�&�Ǫ+�aw��V=T=3��b�0�(���;��6�v.��7�� G�b���#lc�4?/;hE����v>���S <���]&ٽI��F�(>Kv�|vv�L����+��ޑ�f���3 �d�ႍ{h�������.=v9ŀ� �c=��/0g��a�I�Lv1\� ��6ގdUo���c����ΖZ/�RP�х�9���p��dͥ�����{p�j��w�����
Z������y$��
rjV~�)�ya�}����<>�#�l��+@������]�L}����_�Y?�I�{I@Y�e-kqY@��
� �k��j�*�Hg����m��i���L��R_;�Zp1Kq#R_㖠�d5_qI�)!͚�)Yq).���N�J)��f��嫺Gn���a��e)k{m43em��VJ�v
9}��o