![]() |
| SSL certificate error on all browsers, for all HTTPS sites |
Saturday, 28 May 2022
Friday, 20 August 2021
[Tips] How to use Cloudflare Free SSL for Socket.io Server
Free SSL is a very interesting feature of Cloudflare. Cloudflare SSL has full support for WebSocket protocol. However, if you are using the web in conjunction with a socket.io server on the same server, you may encounter problems with the ssl port. Because the default port for ssl is always 443 but it is already used by the web server.
There are many ways to handle this problem, here I will guide you in a very simple way. That's how to configure Socket.io SSL through a proxy using Apache or Nginx.
Prepare:
NodeJs SocketIO server is listen on port 8088
Webserver (Apache or Nginx) is listen on port 80 and 443
Step 1: SocketServer config
Configure NodeJs SocketIO server to run in long polling mode without ssl on a certain port, eg port 8088.
Eg:
var app = require('express')(); //npm install express
var http = require('http').createServer(app);
var socketServer = require('socket.io')(http, { //npm install socketio
cors: {
origin: "*",
methods: ["GET", "POST"]
},
transports: ['polling']
});
http.listen(8088, () => {
console.log('listening on port 8088');
});
Configure socket.io client to use 'polling' mode
Eg:
var socket = io('https://subdomain.yourdomain.com', { });
socket.on('connect', function () {
console.log('connected');
});
Step 2: Configure virtualhost proxy for Socket Server
Configure virtual host proxy to forward port 80 from cloudflare to the actual port of our Socket Server (I listen on port 80 because I am using Cloudflare flexible ssl, if you use Cloudflare full ssl or full strict ssl then listen on port 443 like your other virtualhost)
Apache:
<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
ProxyPreserveHost On
ServerName subdomain.yourdomain.com
ProxyPass / http://127.0.0.1:8088/
ProxyPassReverse / http://127.0.0.1:8088/
</VirtualHost>
Nginx:
server {
listen 80;
server_name subdomain.yourdomain.com;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8088;
}
}
Done !
Remember to reload your web server
Now your NodeJs Socket Server is working perfectly with free ssl from CLoudflare
Thursday, 14 May 2020
Git: How to fix Error Pulling is not possible because you have unmerged files
Error Pulling is not possible because you have unmerged files.
Error: Your local changes to the following files would be overwritten by merge
git add filename1.xyz folder/filename2.xyz
git add -A
git commit -m "Add new file or something need to noted"
git reset --hard origin/master
git pull
Friday, 19 September 2014
MySQL: Allowed to remote connect to MySQL server
STEP 1: Change mysql config :
vi /etc/mysql/my.cnf
Comment out following lines or edit to your client ip :#bind-address = 127.0.0.1
#skip-networking
Restart mysql server:service mysql restart
STEP 2: Change GRANT privilege :Login MySQL using command line .
Then run a command like below to grant access for user. Replace 'username' and 'password' with your username and password.
CREATE USER 'username'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
If it's still not working. Let's check your server firewall (iptables ...) and client firewall (windows firewall, antivirus software)
PHP: Create big unique ID like Facebook or MongoDB
How to do it ?
* SQL AUTO INCREMENT a Field :
--> 1,2,3,4,5..... #anyone can count the number of your records and more
* PHP uniqid :
--> 541cf7f7d685e, 541cf7f7d685e, 541cf7f7d685e ..... #somewhat similar?
* Or use a custom function like this :
function gen_id() {
return sprintf( '%04x%04x%04x%04x%04x%04x%04x%04x',
// 32 bits for "time_low"
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
// 16 bits for "time_mid"
mt_rand( 0, 0xffff ),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand( 0, 0x0fff ) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand( 0, 0x3fff ) | 0x8000,
// 48 bits for "node"
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
);
}
Result : 6800cd499f25434aac48c0bb51f46307, caa02c4831194690ad8458c3a4e07a0c, 7488a4c459d64f8dbacd2b79f44ed4bf ......- differences
- professional (like facebook, google, MongoDB ...)
- high performance
- unrestricted
Reference : PHP uuid lib
Tuesday, 1 April 2014
Excel: How to remove VBA password from excel file
Step by step :
- Download a HEX editor (HxD Hex Editor)
- Open xls/xlsx file and Save As xls. Do this even if the file is xls, just to be sure
- Open xls file with a hex editor
- Search for DPB
- Replace DPB to DPx (Note: the editor overrides, not inserts. So pay attention)
- Save file
- Open file in Excel
- Click "Yes" if you get any message box. There will be a few
- Click Alt + F11
- Click Tools -> [Project Name] Properties
- Click Protection
- Enter a new password twice
- Save
- Close and open the file again
- Type your new password to get to the required information.
Saturday, 7 December 2013
Linux-vsftpd : restrict user to root directory
Open vsftpd configuration file - /etc/vsftpd/vsftpd.conf :
Make sure following line exists and uncommented (add if not exists):
chroot_local_user=YES
Save and close the file. Restart vsftpd service.
/etc/init.d/vsftpd restart
Done. Using a ftp client to check with some acccount.
Friday, 15 November 2013
CSS: Position fixed not working in IE
* Other versions of IE (7,8,9) don't support position: fixed in quirks mode when you missing Doctype.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Saturday, 21 September 2013
QuickTip: Check number of facebook share url
http://graph.facebook.com/http://zero-exception.blogspot.com
Result :{ "id": "http://zero-exception.blogspot.com", "shares": 528, "comments": 39 }


