nginx一个网站实例

13 篇文章 0 订阅

nginx主配置文件

vim /etc/nginx/nginx.conf

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
    use epoll;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;
#    fastcgi_connect_timeout 240;
#    fastcgi_send_timeout 240;
#    fastcgi_read_timeout 240;
#    fastcgi_buffer_size 64k;
#    fastcgi_buffers 4 64k;
#    fastcgi_busy_buffers_size 128k;
#    fastcgi_temp_file_write_size 128k;
#    fastcgi_cache_path /data/ngx_fcgi_cache levels=2:2 keys_zone=ngx_fcgi_cache:2m inactive=1d max_size=50m;

    keepalive_timeout  65;
    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

    gzip  on;
    gzip_min_length        1k;
    gzip_buffers        4 16k;
    gzip_http_version    1.1;
    gzip_comp_level     4;
    gzip_types             text/css text/xml text/md  application/javascript;
    gzip_vary             on;
    server_tokens off;
    server {
       listen 80;
       server_name - ;
       location  / {
        root   /usr/share/nginx/html;
        index  50x.html;
       }
    }
    include /etc/nginx/conf.d/*.conf;
}

nginx代理配置

vim /etc/nginx/proxy_params

proxy_redirect default;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_connect_timeout 30;
proxy_send_timeout 60;
proxy_read_timeout 60;

proxy_buffer_size 32k;
proxy_buffering on;
proxy_buffers 4 128k;
proxy_busy_buffers_size 256k;
proxy_max_temp_file_size 256k;

nginx_server配置

vim /etc/nginx/conf.d/www.wuxingge.org.conf

upstream youmd {
        server 192.168.1.154:8081;
}
server {
        listen 80;
        server_name  www.wuxingge.org wuxingge.org;
        return 302 https://$server_name$request_uri;
}
server {
        listen 443 ssl;
        server_name www.wuxingge.org wuxingge.org;
    ssl_certificate keys/www.wuxingge.org/2572188_www.wuxingge.org.pem;
    ssl_certificate_key keys/www.wuxingge.org/2572188_www.wuxingge.org.key;
    ssl_session_timeout 5m;
    ssl_protocols SSLv2 SSLv3 TLSv1;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    ssl_prefer_server_ciphers on;
        root   /opt/YouMd;
        location / { 
                proxy_pass http://youmd;
                include proxy_params;
				limit_req zone=one burst=3 nodelay;
        }
  if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Yahoo!Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot")
  {
    return 403;
  }
  if ($http_user_agent ~* LWP::Simple|BBBike|wget|ab)
  {
    return 403;
  }
  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  {
    expires      10y;
  }
  location ~ .*\.js$
  {
    expires      30d;
  }
  location ~ .*\.css$
  {
    expires      30d;
  }
}

my index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>wuxingge</title>
    <style>
        body {
            display: flex;
            flex-direction: column;
            min-height: 100vh;
            margin: 0;
        }
        footer {
            margin-top: auto;
            width: 100%;
            height: 60px; /* 根据需要调整高度 */
            background-color: #f0f0f0; /* 背景颜色,根据需要调整 */
            display: flex;
            justify-content: center; /* 水平居中 */
            align-items: center; /* 垂直居中 */
            font-size: 14px; /* 文字大小,根据需要调整 */
        }
        footer a {
            text-decoration: none;
            color: #000; /* 链接颜色,根据需要调整 */
        }
    </style>
</head>
<body>
        <center>
        <h1><a href="http://youxi.wuxingge.online/">wuxingge的小游戏</a></h1>
        <h1><a href="http://baiban.wuxingge.online/">wuxingge的白板</a></h1>
        </center>
<footer>
    <a href="http://beian.miit.gov.cn/" target="_blank">京ICP备20xxxxx号-1</a>
</footer>

</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wuxingge

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值