linux:nginx
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
linux:nginx [2014/04/24 22:52] – [Create a new server block] percy | linux:nginx [2016/05/05 13:07] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Nginx Config ====== | ====== Nginx Config ====== | ||
- | This page is used record some notes when I config a VPS running with Nginx. | + | This page is used to record some notes when I config a VPS running with Nginx. |
===== Create a new server block ===== | ===== Create a new server block ===== | ||
Line 27: | Line 27: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | ===== Revert Proxy ===== | ||
+ | < | ||
+ | server { | ||
+ | server_name wechat.pjq.me; | ||
+ | location / { | ||
+ | proxy_set_header | ||
+ | proxy_set_header | ||
+ | proxy_pass http:// | ||
+ | } | ||
+ | location /doc/ { | ||
+ | alias / | ||
+ | autoindex on; | ||
+ | allow 127.0.0.1; | ||
+ | deny all; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Enable php ===== | ||
+ | | ||
+ | / | ||
+ | |||
+ | < | ||
+ | grep -v -E "# | ||
+ | server { | ||
+ | listen 80; | ||
+ | root / | ||
+ | index index.html index.htm; | ||
+ | server_name | ||
+ | location / { | ||
+ | try_files $uri $uri/ =404; | ||
+ | autoindex on; | ||
+ | } | ||
+ | location ~ \.php$ { | ||
+ | fastcgi_split_path_info ^(.+\.php)(/ | ||
+ | fastcgi_pass unix:/ | ||
+ | fastcgi_index index.php; | ||
+ | include fastcgi_params; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ===== nginx all https ===== | ||
+ | To enable redirect all the http request to https | ||
+ | rewrite ^(.*) https:// | ||
+ | ==== generate the ssl certificate ==== | ||
+ | |||
+ | mkdir / | ||
+ | sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout / | ||
+ | |||
+ | |||
+ | <code file=proxy.pjq.me.conf> | ||
+ | server { | ||
+ | listen 80; | ||
+ | root / | ||
+ | index index.html index.htm index.php; | ||
+ | server_name | ||
+ | rewrite ^(.*) https:// | ||
+ | location / { | ||
+ | try_files $uri $uri/ =404; | ||
+ | autoindex on; | ||
+ | } | ||
+ | location ~ \.php$ { | ||
+ | fastcgi_split_path_info ^(.+\.php)(/ | ||
+ | fastcgi_pass unix:/ | ||
+ | fastcgi_index index.php; | ||
+ | include fastcgi_params; | ||
+ | } | ||
+ | } | ||
+ | server { | ||
+ | listen 443 ssl; | ||
+ | root / | ||
+ | index index.html index.htm index.php; | ||
+ | server_name | ||
+ | ssl_certificate / | ||
+ | ssl_certificate_key / | ||
+ | location / { | ||
+ | try_files $uri $uri/ =404; | ||
+ | autoindex on; | ||
+ | } | ||
+ | location ~ \.php$ { | ||
+ | fastcgi_split_path_info ^(.+\.php)(/ | ||
+ | fastcgi_pass unix:/ | ||
+ | fastcgi_index index.php; | ||
+ | include fastcgi_params; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ |
/var/www/dokuwiki/wiki/data/pages/linux/nginx.txt · Last modified: 2016/05/05 13:07 by 127.0.0.1