Skip to content

Instantly share code, notes, and snippets.

@nickleefly
Last active December 19, 2018 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickleefly/4a725fc9c0843d99b2bea3f122b96678 to your computer and use it in GitHub Desktop.
Save nickleefly/4a725fc9c0843d99b2bea3f122b96678 to your computer and use it in GitHub Desktop.
nginx google ngx_http_google_filter_module
wget https://zlib.net/fossils/zlib-1.2.11.tar.gz
wget https://github.com/openresty/headers-more-nginx-module/archive/v0.33.tar.gz
wget https://www.openssl.org/source/openssl-1.0.2q.tar.gz
wget http://nginx.org/download/nginx-1.15.7.tar.gz
wget http://nginx.org/download/nginx-1.14.2.tar.gz
wget https://www.openssl.org/source/openssl-1.0.2q.tar.gz
wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz

apt-get install build-essential git gcc g++ make
apt-get install libpcre3-dev libssl-dev zlib1g-dev libxslt1-dev libgd-dev libgeoip-dev
apt-get install libxslt-dev
apt-get install libgd-dev
apt-get install libgeoip-dev
apt-get install libpam-dev
apt-get install nginx
service nginx stop
nginx -t

before make install

# create nginx user
sudo adduser --system --home /nonexistent --shell /bin/false --no-create-home --disabled-login --disabled-password --gecos "nginx user" --group nginx
sudo chown nginx:nginx /var/log/nginx/access.log /var/log/nginx/error.log
# check if neccesary files exist
cat /etc/systemd/system/multi-user.target.wants/nginx.service
cat /etc/logrotate.d/nginx
cat /etc/init.d/nginx
ls -l /etc/nginx/
# disable apt-get upgrades on nginx
sudo apt-mark hold nginx
sudo apt-mark hold nginx-core
sudo apt-mark hold nginx:amd64
sudo apt-mark showhold
./configure --prefix=/usr/share/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--user=nginx \
--group=nginx \
--builddir=nginx-1.15.7 \
--with-select_module \
--with-poll_module \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_slice_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--with-mail=dynamic \
--with-mail_ssl_module \
--with-stream=dynamic \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-stream_ssl_preread_module \
--with-compat \
--with-pcre=../pcre-8.42 \
--with-openssl=../openssl-1.0.2q \
--with-zlib=../zlib-1.2.11 \
--with-http_ssl_module \
--add-module=../ngx_http_google_filter_module \
--add-module=../ngx_http_substitutions_filter_module \
--add-module=../headers-more-nginx-module
server {
listen 80;
server_name nick-g.linkpc.net;
resolver 8.8.8.8;
location / {
google on;
google_scholar on;
google_language zh-CN;
}
}
server {
listen 80;
server_name your-dns-address;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name your-dns-address;
ssl_certificate /etc/letsencrypt/some/path/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/some/path/privkey.pem;
resolver 8.8.8.8;
location / {
google on;
google_scholar on;
google_language en;
}
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment