ngnix配置文件
发布日期:2025-04-20 23:45:51 浏览次数:8 分类:精选文章

本文共 2333 字,大约阅读时间需要 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:8000
chdir=/home/login
wsgi-file=/home/login/wsgi.py
home=/env/venv
processes=4
threads=2
master=True
pidfile=uwsgi.pid
daemonize=uwsgi.log
python-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/nginx
        chmod 755 /var/log/nginx
    • ?????

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

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

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

    上一篇:ngrok | 内网穿透,支持 HTTPS、国内访问、静态域名
    下一篇:ngModelController

    发表评论

    最新留言

    留言是一种美德,欢迎回访!
    [***.207.175.100]2025年04月03日 18时22分45秒

    关于作者

        喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
    -- 愿君每日到此一游!

    推荐文章