nginx nginx.conf 代理服务器 配置



#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       80;
        server_name  10.12.6.51;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;

        location / {
        
        proxy_pass http://10.12.6.52:8080;   
    proxy_redirect off;        
    proxy_set_header Host $host;        
    proxy_set_header X-Real-IP $remote_addr;        
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;        
    client_max_body_size 10m; #允许客户端请求的最大单文件字节数       
    client_body_buffer_size 128k;  #缓冲区代理缓冲用户端请求的最大字节数,      
    proxy_connect_timeout 300; #nginx跟后端服务器连接超时时间(代理连接超时)       
    proxy_send_timeout 300; #后端服务器数据回传时间(代理发送超时)       
    proxy_read_timeout 300; #连接成功后,后端服务器响应时间(代理接收超时)        
    proxy_buffer_size 128k;  #设置代理服务器(nginx)保存用户头信息的缓冲区大小       
    proxy_buffers 8 128k;   #proxy_buffers缓冲区,网页平均在32k以下的话,这样设置       
    proxy_busy_buffers_size 256k; #高负荷下缓冲大小(proxy_buffers*2)       
    proxy_temp_file_write_size 128k; #设定缓存文件夹大小,大于这个值,将从upstream服务器传
        }

        #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;
    #    server_name  localhost;


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


    #    ssl_session_timeout  5m;


    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;


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


}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以按照以下步骤来部署 Nginx 并设置 nginx.conf。 1. 首先,确保你的 Linux 服务器上已经安装了 Nginx。如果没有安装,可以使用下面的命令来安装: ``` sudo apt update sudo apt install nginx ``` 2. 安装完成后,打开 nginx.conf 文件进行配置nginx.conf 文件通常位于 `/etc/nginx` 目录下。可以使用以下命令打开该文件: ``` sudo nano /etc/nginx/nginx.conf ``` 3. 在打开的文件中,你可以找到一些默认的配置。根据你的需要进行修改,例如更改默认的监听端口、指定服务器名称等。以下是一个示例的 nginx.conf 配置文件: ``` user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; ## # SSL Settings ## # 如果你有 SSL 证书,可以在这里指定 SSL 相关的配置 ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; # ... 这里可以添加更多的配置 ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } ``` 4. 修改完配置后,保存并关闭 nginx.conf 文件。 5. 接下来,你可以通过以下命令检查 Nginx 配置是否正确: ``` sudo nginx -t ``` 如果没有错误提示,说明配置文件验证通过。 6. 最后,重新启动 Nginx 以使配置生效: ``` sudo service nginx restart ``` 现在,你的 Nginx 服务器应该已经部署并使用了你修改后的 nginx.conf 配置文件。你可以根据需要进一步添加和修改其他配置
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值