Nginx的那些事

来自linux中国网wiki
Evan讨论 | 贡献2020年11月4日 (三) 09:45的版本 →‎nginx conf
跳到导航 跳到搜索

symbolic

有意思的 
  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;




root@debian:/etc/nginx/sites-enabled# pwd
/etc/nginx/sites-enabled
root@debian:/etc/nginx/sites-enabled# file default 
default: symbolic link to /etc/nginx/sites-available/default

nginx conf

80 443 共存

 server
{

listen 80;
listen 443 ssl;
server_name www.iamle.com;
index index.html index.htm index.php;
root /home/wwwroot/www.iamle.com/;
#ssl on; 这里要注释掉
ssl_certificate /usr/local/nginx/conf/ssl/www_iamle_com.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/www_iamle_com.key;

#以下配置省略

}

sns

 cat www.cai.net.conf
upstream proxy_node_nuxt.net {
#fair;
#ip_hash;
#hash $clientRealIp;

#server 176.24.18.94:3333 weight=1 max_fails=2 fail_timeout=10s ;

#old 
#server 172.16.200.14:3333 weight=1 max_fails=2 fail_timeout=10s;
}

server  {
	listen 80;
	listen [::]:80;
	#listen 443 ssl http2;
	#listen [::]:443 ssl http2;    
 
    server_name www.cai.net cai.net;

#     return 301 https://www.cai.net$request_uri;
    rewrite ^(.*)$ https://$host$1 permanent;
}

server {
	listen 443 ssl http2;
	listen [::]:443 ssl http2;    
#    listen 443 ssl;
    server_name www.cai.net cai.net;

#    if ( $host = 'www.cai.net'  )  {
#        rewrite ^/(.*)$ https://www.cai.net/$1 permanent;
#    }
    if ( $host = 'cai.net'  )  {
        rewrite ^/(.*)$ https://www.cai.net/$1 permanent;
    }
   root /data/www/www.cai.net;


    index index.html index.htm;

    ssl_certificate /etc/nginx/ssl/cai.net.crt;
    ssl_certificate_key /etc/nginx/ssl/cai.net.key;

 #by evan
   # if ($scheme = http) {
   #        return 301 https://$server_name$request_uri;
   # } 
 #by evan

    location ~ /360_ssp_verify\.txt {
         root /var/www;
    }

    location /nginx_status {
            stub_status on;
            access_log off;
            allow 183.6.50.25;
            allow 39.104.176.12;
            allow 45.114.170.162;
            allow 127.0.0.1;
            deny all;
        }


    location /download/ {
         root /var/www;
    }

    location ^~ /.well-known/pki-validation/ {
        alias /var/www/pki-validation/;
        log_not_found off;
    }

   merge_slashes off;
   rewrite ^([^.]*?\/)\/+(.*)$ $1$2 permanent;

    location / {
	proxy_pass http://proxy_node_nuxt.net;
    }
##evan


  # 去html
    rewrite  ^/(.+)\.html       /$1 last;
   # rewrite  ^/info/$           /info/alerts/ last;

    error_log /var/log/nginx/www.cai.net.error.log;
    access_log /var/log/nginx/www.cai.net.access.log;
#    include /etc/nginx/sites-available/blockips.conf;
}

Nginx安装

|Nginx-安装与配置(1)