Skip to content

Instantly share code, notes, and snippets.

@krrrr38
Last active August 29, 2015 14:22
Show Gist options
  • Save krrrr38/f76447a6a650450d9256 to your computer and use it in GitHub Desktop.
Save krrrr38/f76447a6a650450d9256 to your computer and use it in GitHub Desktop.
nginx
# http://openresty.org/ : with lua
groupadd -g 501 nginx
sudo useradd -g nginx -u 501 -s /sbin/nologin -d /var/www nginx
sudo yum install -y gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
# normal nginx (or --prefix=/usr/local/nginx)
./configure \
--user=nginx \
--group=nginx \
--prefix=/usr/local/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-ipv6 \
--with-pcre-jit
#Configuration summary
# + using system PCRE library
# + using system OpenSSL library
# + md5: using OpenSSL library
# + sha1: using OpenSSL library
# + using system zlib library
#
# nginx path prefix: "/usr/local/openresty/nginx"
# nginx binary file: "/usr/sbin/nginx"
# nginx configuration prefix: "/etc/nginx"
# nginx configuration file: "/etc/nginx/nginx.conf"
# nginx pid file: "/var/run/nginx.pid"
# nginx error log file: "/var/log/nginx/error.log"
# nginx http access log file: "/var/log/nginx/access.log"
# nginx http client request body temporary files: "client_body_temp"
# nginx http proxy temporary files: "proxy_temp"
# nginx http fastcgi temporary files: "fastcgi_temp"
# nginx http uwsgi temporary files: "uwsgi_temp"
# nginx http scgi temporary files: "scgi_temp"
make
make install
# http://wiki.nginx.org/InitScripts init script
location ~ "^/lua/(.*)$" {
set $route_param $1;
content_by_lua_file '/path/to/sample.lua';
}
## sample.lua
# ngx.say("Hello : " .. ngx.var.route_param)
## request & response
#[vagrant@localhost ~]$ curl -k https://localhost/lua/access
#Hello : access
$ openssl genrsa -des3 -out server.key 2048
$ openssl req -new -key server.key -out server.csr
$ openssl rsa -in server.key -out server.key
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
server {
listen 443 ssl;
ssl on;
ssl_certificate /etc/nginx/server.crt;
ssl_certificate_key /etc/nginx/server.key;
proxy_set_header Host $host;
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 $host;
#proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Real-IP $remote_addr;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment