应用部署目录


mkdir -p /opt/apps/nginx/conf   #认证文件
mkdir -p /opt/apps/nginx/conf #配置文件
mkdir -p /opt/apps/ #配置文件

mkdir -p /opt/lib/nginx/nginx-1.25.1/conf/ssl   #认证文件
mkdir -p /opt/lib/nginx/nginx-1.25.1/conf/vhost #配置文件


mkdir -p /opt/apps/apis #仅接口文件应用部署路径(后端)
mkdir -p /opt/apps/webs #仅前端文件应用部署路径(前端)
mkdir -p /opt/apps/alls #仅前端文件应用部署路径(前端+后端)
mkdir -p /opt/apps/cdn # js+css 等公共静态数据
mkdir -p /opt/apps/files #文件上传存储目录

软链接,后面是目标,前面是实际路径

把ssl文件映射到conf目录


ln -s /opt/lib/nginx/nginx-1.25.1/conf/ssl /opt/apps/nginx/conf
ln -s /opt/lib/nginx/nginx-1.25.1/conf/vhost /opt/apps/nginx/conf

配置内容


#user  nobody;
worker_processes  60;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    server_names_hash_bucket_size 64;
    include       mime.types;
    default_type  application/octet-stream;

    #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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    gzip on;
    gzip_buffers 32 4K;
    gzip_comp_level 6;
    gzip_min_length 100;
    gzip_types application/javascript text/css text/xml;
    gzip_disable "MSIE [1-6]\."; #配置禁用gzip条件,支持正则。此处表示ie6及以下不启用gzip(因为ie低版本不支持)
    gzip_vary on;

# 在http上下文中增加如下配置,确保Nginx能处理正常http请求。
map $http_upgrade $connection_upgrade {
          default upgrade;
          '' close;
}
    include vhost/*.conf; #加载vhost目录下的虚拟主机配置文件 
    #server {
        #listen       80;
        #server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        #location / {
        #    root   html;
        #    index  index.html index.htm;
        #}

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        #error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
        #    root   html;
        #}

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    #}


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
文档更新时间: 2023-08-22 23:20   作者:admin