宝塔部署-Nginx配置

复制代码
user  root;
worker_processes auto;
error_log  /www/wwwlogs/nginx_error.log  crit;
pid        /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

stream {
    log_format tcp_format '$time_local|$remote_addr|$protocol|$status|$bytes_sent|$bytes_received|$session_time|$upstream_addr|$upstream_bytes_sent|$upstream_bytes_received|$upstream_connect_time';
  
    access_log /www/wwwlogs/tcp-access.log tcp_format;
    error_log /www/wwwlogs/tcp-error.log;
    include /www/server/panel/vhost/nginx/tcp/*.conf;
}

events
    {
        use epoll;
        worker_connections 51200;
        multi_accept on;
    }

http
    {
        include       mime.types;
		#include luawaf.conf;

		include proxy.conf;
        lua_package_path "/www/server/nginx/lib/lua/?.lua;;";

        default_type  application/octet-stream;

        server_names_hash_bucket_size 512;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 60;

        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;
		fastcgi_intercept_errors on;

        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 5;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/json image/jpeg image/gif image/png font/ttf font/otf image/svg+xml application/xml+rss text/x-js;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";

        limit_conn_zone $binary_remote_addr zone=perip:10m;
		limit_conn_zone $server_name zone=perserver:10m;

        server_tokens off;
        access_log off;

server
    {
        listen 80;
        server_name 114.55.234.99;
        index index.html index.htm index.php;
        root  /www/wwwroot/project/dist/;
        
        location /prod-api/ {
          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_pass http://127.0.0.1:8080/;
        }
	location / {
        	try_files $uri $uri/ /index.html;
    	}

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /www/wwwlogs/access.log;
    }
include /www/server/panel/vhost/nginx/*.conf;
}

开头改成user root;

server部分需修改。

注意location /prod-api/ 的proxy_pass为proxy_pass http://127.0.0.1:8080/;

相关推荐
我科绝伦(Huanhuan Zhou)9 分钟前
Oracle控制文件、SCN与检查点机制深度解析及数据库初始化原理
运维·数据库·oracle
杨云龙UP32 分钟前
从0到可落地:Oracle RMAN异地NFS备份标准脚本(多实例通用)
linux·运维·数据库·oracle
黑客思维者37 分钟前
嵌入式系统DevSecOps深度设计:构建固件级漏洞免疫体系的自动化管道
运维·自动化·devsecops·嵌入式系统
ZKNOW甄知科技2 小时前
AI-ITSM的时代正在到来:深度解读Gartner最新报告
大数据·运维·人工智能·低代码·网络安全·微服务·重构
4t4run2 小时前
21、Linux常用命令-进程内存CPU相关命令
linux·运维·服务器
weixin_307779132 小时前
Jenkins Ioncions API 插件:现代化图标库在持续集成中的应用
java·运维·开发语言·前端·jenkins
用户6135411460162 小时前
nginx-sticky怎么用 Nginx 负载均衡添加 sticky 模块完整步骤
nginx
行初心2 小时前
uos基础 systemd-resolve 命令执行报错与参考处理方法
运维
小陈phd2 小时前
langgraph从入门到精通(一)——langgraph概念解析
linux·运维·数据库