博客
关于我
Nginx入门教程-简介、安装、反向代理、负载均衡、动静分离使用实例
阅读量:793 次
发布时间:2023-02-15

本文共 2606 字,大约阅读时间需要 8 分钟。

????Nginx??????

Nginx????????Web??????????????????????????????????????????Nginx??????????????????????????????????????????????????????

Ubuntu 16.04 LTS????Nginx??

?Ubuntu?????Nginx?????????????

  • ??????
  • sudo apt update
    1. ??Nginx?
    2. sudo apt install nginx
      1. ??????????
      2. sudo systemctl start nginxsudo systemctl enable nginx

        ??????Nginx????????????IP????????????????

        Nginx???????

        ?????????Nginx????????????????????????

        • ???????
        nginx -v
        • ?????
        sudo systemctl restart nginx
        • ???????
        sudo tail -f /var/log/nginx/access.log
        • ???????
        sudo nginx -C

        ??????????????????????????

        Nginx??????????

        Nginx?????????/etc/nginx/sites-available/default???????????????????????????????????

      3. ???????

        • events???????????????worker_connections???????????
      4. ?????

        • server??????listen???????
        • listen???????????????????SNI?
        • server_name????????????????IP???
      5. ????

        • location?????URL??????????????????
        • try_files????????????????????????????404???
      6. ??????

        • types???MIME?????????????????
      7. ?????

        • gzip?????????????????
        • ssl???SSL/TLS????????
      8. ??????????????????Nginx???????????????

        Nginx?????????

        ?????Nginx???????????????????????????????????????????????

        server {    listen 80;    server_name your_domain.com;    location / {        proxy_pass http://backend_server:8000;        proxy_set_header Host $host;        proxy_set_header X-Real-IP $remote_addr;        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;        proxy_set_header X-Forwarded-Proto $scheme;    }}
        • proxy_pass????????????????????????????8000???
        • proxy_set_header?????HTTP???????????????????

        ???????Nginx??????????????????????????????

        Nginx??????????

        ????????????????????????????????????IP???????????????????????????

        server {    listen 80;    server_name domain.com;    location / {        proxy_pass http://server1:8000;        proxy_pass http://server2:8000;        proxy_pass http://server3:8000;        proxy_set_header X-Served-By $upstream_addr;    }}
        • proxy_pass????server???Nginx???IP?????????????????
        • proxy_set_header X-Served-By?????????????????????

        ????????????????????????????????????????????????????

        Nginx?????????

        ???????Nginx???????????????????????????????????????????

        server {    listen 80;    server_name your_domain.com;    location / {        root /var/www/static;        index index.html;        location /app {            proxy_pass http://backend:8000;            proxy_set_header Host $host;        }    }}
        • root?????????????
        • index????????????index.html?
        • location /app?????????????????????

        ???????Nginx????????????????????????????????????????????

        ??

        Nginx??????????Web?????????????????????????????????????Nginx??????????????????????????????????????????????????????????

    转载地址:http://mhcfk.baihongyu.com/

    你可能感兴趣的文章
    Netty源码—3.Reactor线程模型三
    查看>>
    Netty源码—3.Reactor线程模型四
    查看>>
    Netty源码—4.客户端接入流程一
    查看>>
    Netty源码—4.客户端接入流程二
    查看>>
    Netty源码—5.Pipeline和Handler一
    查看>>
    Netty源码—5.Pipeline和Handler二
    查看>>
    Netty源码—6.ByteBuf原理一
    查看>>
    Netty源码—6.ByteBuf原理二
    查看>>
    Netty源码—7.ByteBuf原理三
    查看>>
    Netty源码—7.ByteBuf原理四
    查看>>
    Netty源码—8.编解码原理一
    查看>>
    Netty源码—8.编解码原理二
    查看>>
    Netty源码解读
    查看>>
    netty的HelloWorld演示
    查看>>
    Netty的Socket编程详解-搭建服务端与客户端并进行数据传输
    查看>>
    Netty的网络框架差点让我一夜秃头,哭了
    查看>>
    Netty相关
    查看>>
    Netty简介
    查看>>
    Netty线程模型理解
    查看>>
    netty解决tcp粘包和拆包问题
    查看>>