File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /* Minimal SSL/non-SSL example using PROXY Protocol v2 */
2+
3+ const uWS = require ( '../dist/uws.js' ) ;
4+ const port = 3000 ;
5+
6+ const app = uWS . /*SSL*/ App ( {
7+ key_file_name : 'misc/key.pem' ,
8+ cert_file_name : 'misc/cert.pem' ,
9+ passphrase : '1234'
10+ } ) . get ( '/*' , ( res , req ) => {
11+ /* Respond with their addresses */
12+ res . cork ( ( ) => {
13+ res . write ( '<html><h1>' ) ;
14+ res . write ( 'Your proxied IP is: ' + Buffer . from ( res . getProxiedRemoteAddressAsText ( ) ) . toString ( ) ) ;
15+ res . write ( '</h1><h1>' ) ;
16+ res . write ( 'Your IP as seen by the origin server is: ' + Buffer . from ( res . getRemoteAddressAsText ( ) ) . toString ( ) ) ;
17+ res . end ( '</h1></html>' ) ;
18+ } ) ;
19+ } ) . listen ( port , ( listenSocket ) => {
20+ if ( listenSocket ) {
21+ console . log ( 'Listening to port ' + port ) ;
22+ } else {
23+ console . log ( 'Failed to listen to port ' + port ) ;
24+ }
25+ } ) ;
You can’t perform that action at this time.
0 commit comments