IT虾米网

nginx常用配置(仅供参考)

wyy 2022年05月14日 程序员 171 0
user  root; 
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; 
 
    # gzip  on; 
    # gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml; 
     
    # 负载均衡 
    # upstream mysite.com { 
    #     server localhost:8081; 
    #     server localhost:8082; 
    #     server localhost:8083; 
    #     server localhost:8084; 
    #     server localhost:8085; 
    #     hash $request_uri; 
    # } 
 
    server { 
        listen 8080; 
        server_name  localhost; 
         
        # hash mode 
        location / { 
            root /srv/; 
            index index.html; 
        } 
 
        # history mode 
        # location / { 
        #     root   /srv/; 
        #     try_files $uri $uri/ /index.html; 
        # } 
 
        # api proxy 
        # location ^~ /api/ { # 注意末尾的"/" 
        #     proxy_pass  http://mysite.com/; # 注意末尾的"/" 
        # } 
 
        # socket proxy 
        # location ^~ /socket/ { 
        #   proxy_pass http://mysite.com/socket/; 
        #   proxy_http_version 1.1; 
        #   proxy_set_header Upgrade $http_upgrade; 
        #   proxy_set_header Connection "upgrade"; 
        # } 
 
    } 
 
    # 负载均衡 
    # server { 
    #     listen      8081; 
    #     server_name  localhost; 
    #     location / { 
    #         proxy_pass http://ip1.com; 
    #     } 
    # } 
    # server { 
    #     listen      8082; 
    #     server_name  localhost; 
    #     location / { 
    #         proxy_pass http://ip2.com; 
    #     } 
    # } 
 
} 
 

评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

Linux安装Nginx服务器