Ferro's Gitbook
  • README
  • DevOps
    • Grafana_Cloud
  • OpenWrt
    • DHCP_DNS
    • GLiNet
    • boot
    • captive_portal
    • luci
    • mwan3
    • radius
    • theme
    • wireless
  • apps
    • web
  • BSD
    • Mac
  • Cloud
    • aws
    • azure
    • cf
    • gcp
    • github
    • ibm_bluemix
    • Pricing
  • container
    • docker
    • Kubernetes
    • podman
  • db
    • InfluxDB
    • loki
    • MySQL & MariaDB
    • Oracle
    • PostgreSQL
  • dev
    • AHK
    • BI
    • LBS
    • ML
    • android
    • editor
    • flutter_web
    • git
    • go
    • HTML5/BS
    • j2ee
    • js
    • js_grid
    • js_vue
    • jupyter
    • ocaml
    • powershell
    • py
    • py_GUI
    • Django
    • shell
    • snippets
    • uni
    • vba
    • wechat.zh
    • wechat_mp.zh
  • elec
    • 3D Printing
    • AC
    • MOSFET
    • battery
    • boost
    • bulk
    • metal
    • simulator
  • hw
    • GPU
    • PCI
    • arduino
    • Bluetooth
    • ent
    • Pinout
    • x86_AMD
    • x86_intel
  • linux
    • Test System
    • X
    • arch
    • fs
    • kernel
    • Memory
    • nw
    • Linux Services
    • Systemd
    • text
  • ms
    • vscode
    • windows
    • wsl
  • multimedia
    • Blender
    • audio
    • blender
    • graphics
    • home
  • nw
    • L3
    • L3_IPv6
    • SDN
    • VPN
    • dns
    • hw
    • Low Level
    • mikrotik
    • mwan
    • Openflow
    • OVS
    • pfsense
    • ppp
    • proxy
    • tsocks
    • pxe
    • Security
    • TCP
  • phone
    • Mi
    • android
  • Storage(SW)
  • vt
    • Intel GVT-g
    • PVE
    • QEMU
    • VDI
    • hyper-v
    • kube
    • libvirt
    • OpenStack
  • Web
    • IBM_MQ
    • IBM_Websphere
    • SSL
    • Apache/IBM_IHS
    • blockchain
    • caddy
    • j2ee
    • nginx
    • static_site
Powered by GitBook
On this page
  • plain text/index/debug
  • Forward Proxy
  • Reverse Proxy
  • For Google

Was this helpful?

Edit on Git
  1. Web

nginx

Previousj2eeNextstatic_site

Last updated 4 years ago

Was this helpful?

plain text/index/debug

worker_processes  5;  ## Default: 1

location /code/ {
    location ~* { # All files in it
        add_header Content-Type text/plain;                      # Display file as text
    }
}

location /sub_dir {
    autoindex on;                                                # list dir files
    autoindex_exact_size off;
    charset utf-8;
    root /root_path

    error_log /var/logs/nginx/debug.log debug;                   #   Debug
    # debug, info, notice, warn, error, crit, alert, or emerg
}

Forward Proxy

server {
    listen  443;

    # dns resolver used by forward proxying
    resolver  114.114.114.114;

    # forward proxy for CONNECT request
    proxy_connect;
    proxy_connect_allow            443;
    proxy_connect_connect_timeout  10s;
    proxy_connect_read_timeout     10s;
    proxy_connect_send_timeout     10s;

    # forward proxy for non-CONNECT request
    location / {
        proxy_pass http://$host;
        proxy_set_header Host $host;
    }
}

Reverse Proxy

upstream backend {
    server backend1.example.com       weight=5; # by default 1
    server backend2.example.com:8080;
    server unix:/tmp/backend3;

    server backup1.example.com:8080   backup;
    server backup2.example.com:8080   backup;
}

server {
    location / {
        proxy_pass http://backend;  # same name of upstream
    }
}

Nginx health checks is available as part of commercial subscription.

For Google

docker run -p 80:80 -d bohan/onemirror

OneMirror is a Docker image of Nginx, which already configured Google Search, Google Fonts and Gravatar proxy.

https://www.alibabacloud.com/blog/how-to-use-nginx-as-an-https-forward-proxy-server_595799
http://nginx.org/en/docs/http/ngx_http_upstream_hc_module.html
https://github.com/bohanyang/onemirror
https://www.nginx.com/resources/wiki/start/topics/examples/full/
plain text/index/debug
Forward Proxy
Reverse Proxy
For Google