Skip to content

Instantly share code, notes, and snippets.

@negima1976
negima1976 / mruby-request-method-hanlder.rb
Last active January 13, 2016 06:21
Deny a connection other than the specific request method.
lambda do |env|
if /^(GET|POST|HEAD)/.match(env(["REQUEST_METHOD"]))
return [200, {},[]]
end
[405, {'content-type' => 'text/plain'}, ["Method Not Allowed\n"]]
end
@negima1976
negima1976 / h2o.service
Created October 19, 2015 00:12
h2o systemd service file
[Unit]
Description=H2O the optimized HTTP/1, HTTP/2 server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/var/run/h2o/h2o.pid
ExecStartPre=/usr/local/bin/h2o -c /etc/h2o/h2o.conf -t
ExecStart=/usr/local/bin/h2o -c /etc/h2o/h2o.conf -m daemon
ExecReload=/bin/kill -s HUP $MAINPID
@negima1976
negima1976 / h2ossl.conf
Created August 22, 2015 00:55
h2o SSLの設定
user: nobody
listen:
port: 80
host: 0.0.0.0
listen:
port: 443
ssl:
key-file: /etc/pki/tls/private/server.key
certificate-file: /etc/pki/tls/certs/server.pem
@negima1976
negima1976 / openssl_check.txt
Created August 19, 2015 09:16
opensslでの各種チェックコマンド
#証明書ファイルの内容を確認
$openssl x509 -text -noout -in /etc/pki/tls/certs/server.crt
#秘密鍵ファイルの内容を確認
$openssl rsa -text -noout -in /etc/pki/tls/private/server.key
#CSRファイルの内容を確認
$openssl req -text -noout -in /home/hoge/ssl/server.csr
#簡易サーバを立てての確認
$openssl s_server -accept 10443 -cert server.crt -key server.key -CAfile server.ca -WWW
$curl -v https://localhost:10443/
@negima1976
negima1976 / h2o.conf
Last active August 29, 2015 14:27
Nginx + FastCGI + WordPress→h2o + FastCGI + WordPress
user: nobody
listen:
port: 80
host: 0.0.0.0
file.index: ['index.php', 'index.html']
file.send-gzip: ON
file.etag: OFF
expires: 1 day
@negima1976
negima1976 / Makefile
Created November 21, 2013 07:45
net-snmp-config-module install for 64bit
NAME = net-snmp-lvs-module
VERSION=$(shell cat VERSION)
VERSDIR := $(NAME)-$(VERSION)
TARFILE := $(NAME)-$(VERSION).tar.gz
CC := gcc
CFLAGS := -fPIC `net-snmp-config --cflags` -Ilibipvs -I/usr/local/src/linux-2.6.32.27/include -Wall -g
DEFINES := -DHAVE_NET_IP_VS_H
DLFLAGS := -fPIC -shared -g
LIBS := `net-snmp-config --netsnmp-libs`
LIBIPVS := libipvs/libipvs.a
@negima1976
negima1976 / gist:6447630
Created September 5, 2013 08:50
perl sample code
#!/usr/bin/perl
use strict;
use warnings;
my $app = sub {
my $env = shift;
return [ 200,
[ 'Content-Type' => 'text/plain' ],
[ "Hello World" ],
];
@negima1976
negima1976 / gist:4153253
Created November 27, 2012 09:05
ss_tcp_connections.php
--- ss_tcp_connections_old.php 2012-11-28 02:59:13.074710576 +0900
+++ ss_tcp_connections_new.php 2012-11-28 02:46:47.472714312 +0900
@@ -1,25 +1,30 @@
<?php
-/* do NOT run this script through a web browser */
+require_once 'Console/CommandLine.php';
-if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) {
- die("<br><strong>This script is only meant to run at the command line.</strong>");
+$parser = new Console_CommandLine(array(
@negima1976
negima1976 / hssample.pl
Created November 27, 2012 01:49
HandlerSocket sample code
#!/usr/bin/perl
use strict;
use warnings;
use Net::HandlerSocket;
use Data::Dumper qw/Dumper/;
my $args = { host => 'localhost', port => 9998 };
my $hs = new Net::HandlerSocket($args);
@negima1976
negima1976 / daily_log_count.awk
Created May 1, 2012 06:23
ログファイルの行数を日付ごとに出力
#/usr/bin/gawk -f
BEGIN {
for (i = 1;i < ARGC;i ++) {
cnt = 0;
while(getline < ARGV[i] > 0) {
cnt ++;
}
print ARGV[i]":"cnt
}
}