linux:nginx
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| linux:nginx [2014/04/24 22:48] – created 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 10: | Line 10: | ||
| | | ||
| root / | root / | ||
| + | | ||
| Then enable this site: | Then enable this site: | ||
| ln -s / | ln -s / | ||
| / | / | ||
| So the site is running, cheers. | So the site is running, cheers. | ||
| + | ===== Enable directory list ===== | ||
| + | Add " | ||
| + | < | ||
| + | | ||
| + | # First attempt to serve request as file, then | ||
| + | # as directory, then fall back to displaying a 404. | ||
| + | try_files $uri $uri/ =404; | ||
| + | # Uncomment to enable naxsi on this location | ||
| + | # include / | ||
| + | autoindex on; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== 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/attic/linux/nginx.1398350883.txt.gz · Last modified: 2016/05/05 13:06 (external edit)
