Nginx 基础配置文件

简介: Nginx 基础配置文件

基础配置文件:

#user  nobody;
worker_processes  1;

#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 {
    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;

    server {
        listen       81;
        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;
    #    }
    #}
    
}

最基础配置文件:

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       81;
        server_name  localhost;
        
        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

前台配置:

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;


    server {
        listen       80;
        server_name  localhost;

        location / {
            root   /usr/local/nginx/html/dist;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
        }

    location /api/ {        
            proxy_pass http://www.api.nanjustar.top;
            proxy_cookie_path / /api;
            rewrite ^/api/(.*) /$1 break;
        }

    }
}
目录
相关文章
|
4月前
|
应用服务中间件 nginx
Nginx 配置文件详解
Nginx 配置文件详解
56 0
|
7月前
|
应用服务中间件 Linux nginx
Mac Nginx 配置文件使用(nginx.conf,包含M1)
Mac Nginx 配置文件使用(nginx.conf,包含M1)
275 0
|
21天前
|
运维 应用服务中间件 Linux
LNMP详解(五)——Nginx主配置文件详解
LNMP详解(五)——Nginx主配置文件详解
17 1
|
1月前
|
负载均衡 应用服务中间件 nginx
|
7月前
|
应用服务中间件 nginx Docker
在 Docker 中部署 Nginx 并挂载配置文件
在 Docker 中部署 Nginx 并挂载配置文件
|
2月前
|
Ubuntu 应用服务中间件 nginx
ubuntu环境下 nginx 怎么配置文件
ubuntu环境下 nginx 怎么配置文件
|
3月前
|
负载均衡 NoSQL 应用服务中间件
Nginx编译安装及配置文件详解
Nginx编译安装及配置文件详解
|
8月前
|
运维 应用服务中间件 nginx
nginx--配置文件详解、错误页面的配置
nginx--配置文件详解、错误页面的配置
|
3月前
|
应用服务中间件 nginx
上传文件失败413 Request Entity Too Large,nginx配置文件大小的限制
上传文件失败413 Request Entity Too Large,nginx配置文件大小的限制
|
4月前
|
缓存 负载均衡 应用服务中间件
Nginx配置文件详解与配置
Nginx配置文件详解与配置
349 0