Difference between revisions of "Nginx"
Line 20: | Line 20: | ||
make | make | ||
make install | make install | ||
that puts it in the middle of nowhere with no systenctl or usr/sbinin | |||
in ls -al /etc/systemd/system/multi-user.target.wants/ there should be nginx.service -> /lib/systemd/system/nginx.service and there should be the file nginx.service which looks like this | |||
<pre> | |||
# Stop dance for nginx | |||
# ======================= | |||
# | |||
# ExecStop sends SIGSTOP (graceful stop) to the nginx process. | |||
# If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control | |||
# and sends SIGTERM (fast shutdown) to the main process. | |||
# After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends | |||
# SIGKILL to all the remaining processes in the process group (KillMode=mixed). | |||
# | |||
# nginx signals reference doc: | |||
# http://nginx.org/en/docs/control.html | |||
# | |||
[Unit] | |||
Description=A high performance web server and a reverse proxy server | |||
After=network.target | |||
[Service] | |||
Type=forking | |||
PIDFile=/run/nginx.pid | |||
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;' | |||
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;' | |||
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload | |||
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid | |||
TimeoutStopSec=5 | |||
KillMode=mixed | |||
[Install] | |||
WantedBy=multi-user.target | |||
</pre> | |||
and since nginx isn't there you need | |||
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/ | |||
===reverse proxy=== | ===reverse proxy=== | ||
https://github.com/yaoweibin/nginx_tcp_proxy_module | https://github.com/yaoweibin/nginx_tcp_proxy_module |
Revision as of 21:31, 29 January 2017
Nginx
tcp proxy
http://yaoweibin.github.io/nginx_tcp_proxy_module/
wget http://github.com/yaoweibin/nginx_tcp_proxy_module/tarball/master tar -xvf master cd yaoweibin-nginx_tcp_proxy_module-7d70702 cp -R yaoweibin-nginx_tcp_proxy_module-7d70702 /opt sudo apt-get install -y dpkg-dev sudo apt-get install libpcre++-dev sudo mkdir /opt/rebuildnginx cd /opt/rebuildnginx sudo apt-get source nginx cd /opt/rebuildnginx/nginx-1.10.0/ patch -p1 < /opt/yaoweibin-nginx_tcp_proxy_module-7d70702/tcp.patch ./configure --add-module=/opt/yaoweibin-nginx_tcp_proxy_module-7d70702 make make install
that puts it in the middle of nowhere with no systenctl or usr/sbinin
in ls -al /etc/systemd/system/multi-user.target.wants/ there should be nginx.service -> /lib/systemd/system/nginx.service and there should be the file nginx.service which looks like this
# Stop dance for nginx # ======================= # # ExecStop sends SIGSTOP (graceful stop) to the nginx process. # If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control # and sends SIGTERM (fast shutdown) to the main process. # After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends # SIGKILL to all the remaining processes in the process group (KillMode=mixed). # # nginx signals reference doc: # http://nginx.org/en/docs/control.html # [Unit] Description=A high performance web server and a reverse proxy server After=network.target [Service] Type=forking PIDFile=/run/nginx.pid ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;' ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;' ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid TimeoutStopSec=5 KillMode=mixed [Install] WantedBy=multi-user.target
and since nginx isn't there you need
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
reverse proxy
https://github.com/yaoweibin/nginx_tcp_proxy_module
https://github.com/imZack/docker-nginx-tcp-proxy
websocket reverse proxy
https://www.nginx.com/blog/websocket-nginx/
restart nginx
nginx -s reload
allow directory reads
edit
/etc/nginx/sites-available/default
add autoindex on here
location / { try_files $uri $uri/ =404; autoindex on; }
restart
nginx -s reload
install
https://anturis.com/blog/nginx-vs-apache/
SSL
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com sudo ln -s /etc/nginx/sites-available/cascada.parleyvale.com /etc/nginx/sites-enabled/cascada.parleyvale.com
server { listen 443; server_name stuff2get.parleyvale.com; root /home/stuff2get/www; index index.html index.htm; ssl on; ssl_certificate /etc/nginx/ssl/stuff2get.parleyvale.com/server.crt; ssl_certificate_key /etc/nginx/ssl/stuff2get.parleyvale.com/server.key; }
server { listen 443; server_name stuff2get.parleyvale.com; location / { proxy_pass http://localhost:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } ssl on; ssl_certificate /etc/nginx/ssl/stuff2get.parleyvale.com/server.crt; ssl_certificate_key /etc/nginx/ssl/stuff2get.parleyvale.com/server.key; }