博客
关于我
ngnix配置文件
阅读量:799 次
发布时间:2023-02-15

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

Nginx???????

1. ??????

1.1 ????

worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;# ??????include /usr/share/doc/nginx/README.dynamic.include;include /usr/share/nginx/modules/*.conf;

1.2 ????

events {    worker_connections 1024;}

1.3 ????

http {    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;    tcp_nodelay on;    keepalive_timeout 65;    types_hash_max_size 2048;    include /etc/nginx/mime.types;    default_type application/octet-stream;        # ??????    include /etc/nginx/conf.d/*.conf;}

1.4 ??????

server {    listen 80;    server_name www.yblisgglib.online;        # ???????HTTPS    rewrite ^/(.*) https://www.yblisgglib.online/$1 permanent;}server {    listen 443 ssl;    server_name www.yblisgglib.online;        # ??????    access_log /var/log/nginx/example.com_access.log combined;    error_log /var/log/nginx/example.com_error.log error;        # ????    ssl_certificate /etc/nginx/cert/4296312_yblisgglib.online.pem;    ssl_certificate_key /etc/nginx/cert/4296312_yblisgglib.online.key;        # ??????    location /static {        alias /home/login/static;    }        # ????    location / {        include uwsgi_params;        uwsgi_pass 127.0.0.1:8000;        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;    }}

2. uwsgi.ini??

[uwsgi]socket=127.0.0.1:8000chdir=/home/loginwsgi-file=/home/login/wsgi.pyhome=/env/venvprocesses=4threads=2master=Truepidfile=uwsgi.piddaemonize=uwsgi.logpython-autoreload=1

3. ????????

3.1 ????

  • ??????????????????403 Forbidden?404 Not Found????????Nginx????????????

3.2 ????

  • ???????

    • ?????????????
      location /static {    alias /home/login/static;}
    • ??/home/login/static???????
  • ?????

    • ????????????Nginx?????????????
  • ?????

    • ?????????Nginx???
      sudo systemctl restart nginx
  • 4. ????

    • ???????

      • ????????????????#????????
    • ?????

      • ???????????
        mkdir -p /var/log/nginxchmod 755 /var/log/nginx
    • ?????

      • ??SSL????????????????????
    • uwsgi???

      • ??uwsgi????????????????127.0.0.1:8000?

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

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

    你可能感兴趣的文章
    Nginx负载均衡详解
    查看>>
    Nginx负载均衡(upstream)
    查看>>
    nginx转发端口时与导致websocket不生效
    查看>>
    Nginx运维与实战(二)-Https配置
    查看>>
    Nginx部署_mysql代理_redis代理_phoenix代理_xxljob代理_websocket代理_Nacos代理_内网穿透代理_多系统转发---记录021_大数据工作笔记0181
    查看>>
    nginx部署本地项目如何让异地公网访问?服务器端口映射配置!
    查看>>
    Nginx配置HTTPS服务
    查看>>
    Nginx配置Https证书
    查看>>
    Nginx配置http跳转https
    查看>>
    Nginx配置ssl实现https
    查看>>
    nginx配置ssl证书https解决公网ip可以访问但是域名不行的问题
    查看>>
    Nginx配置TCP代理指南
    查看>>
    NGINX配置TCP连接双向SSL
    查看>>
    Nginx配置——不记录指定文件类型日志
    查看>>
    nginx配置一、二级域名、多域名对应(api接口、前端网站、后台管理网站)
    查看>>
    nginx配置中的服务器名称
    查看>>
    Nginx配置代理解决本地html进行ajax请求接口跨域问题
    查看>>
    nginx配置全解
    查看>>
    Nginx配置参数中文说明
    查看>>
    Nginx配置后台网关映射路径
    查看>>