宝塔部署-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/;

相关推荐
l1l2x1x227 分钟前
DNS配置作业
运维·服务器
wanhengidc1 小时前
云手机的核心价值
运维·游戏·智能手机·云计算
Lynnxiaowen1 小时前
今天我们开始学习ansible之playbook的简单运用
linux·运维·学习·云计算·ansible
心无旁骛~2 小时前
Docker常见命令
运维·docker·容器
挠到秃头的涛某2 小时前
华为防火墙web配置SSL-在外人员访问内网资源
运维·网络·网络协议·tcp/ip·华为·ssl·防火墙
吉普赛的歌2 小时前
【服务器】查看IIS上某个网站的当前连接数
运维·服务器
mzlogin3 小时前
解决访问 https 网站时,后端重定向或获取 URL 变成 http 的问题
java·后端·nginx
在这habit之下3 小时前
nginx介绍与简单操作
运维·nginx
小小测试开发3 小时前
JMeter 自动化实战:自动生成文件并传参接口的完整方案
运维·jmeter·自动化
门思科技4 小时前
LoRaWAN通信协议详解:架构、加密机制与核心应用
运维·服务器·网络·嵌入式硬件·物联网