本站nginx配置文件

主要就是对搜索引擎蜘蛛的转发处理,其他的配置跟普通项目没区别

下面蜘蛛的ip地址我改过了,建议大家如果部署的时候也别暴露这个地址,被人一直访问,就可能导致蜘蛛访问很慢,影响收录。

不同的项目放到不同的二级域名,比如我:

前台就用 noxue.com

后台用 admin.noxue.com 后台也尽量别暴露了,虽然暴露了也没什么

upstream gocms {
  server 127.0.0.1:9999;
}
upstream zhizhu {
  server 48.99.171.67;
}

server {
    listen 80;
    server_name api.noxue.com;
    location ~ / {
        proxy_pass http://gocms;
    }
}

server {
    listen      80;
    server_name noxue.com www.noxue.com *.noxue.com;
    root        "/usr/local/www/gocms";
    index       index.html;

    charset     utf-8;
    if ($host != 'noxue.com' ) {
        rewrite ^/(.*)$ http://noxue.com/$1 permanent;
    }

    location /{
        if ($http_user_agent ~* "baidu|robot|spider|bing|google|sougou|sogo|soso|yahoo|youdao|uc") {
            proxy_pass http://zhizhu;
        }
        try_files $uri $uri/ /index.html;
        index  index.html index.htm;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    sendfile   off;

    client_max_body_size 100m;

    location ~ /\.ht {
        deny all;
    }
}

server {
    listen      80;
    server_name admin.noxue.com;
    root        "/usr/local/www/gocms-admin";
    index       index.html;


    charset     utf-8;
    location /{
        try_files $uri $uri/ /index.html
        index  index.html index.htm;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    sendfile   off;

    client_max_body_size 100m;

    location ~ /\.ht {
        deny all;
    }
}