云服务器:如何给Nginx绑定多个端口

发布时间:2021-09-23

  有两种方法:一、在server段写上2个Listen就可以了.listen 192.168.0.123:8080;
listen 192.168.0.123:8089;
如上,就可以同时2个端口了.

  二、在f 中配置多个个server即可usernginxnginx;worker_processes1;worker_rlimit_nofile65535;events{worker_connections4000; }http{includemime.types;default_typeapplication/octet-stream;autoindexoff;log_formatmain$remote_addr-$remote_user[$time_local]$request $status$body_bytes_sent$http_referer $http_user_agent$http_x_forwarded_for $upstream_addr$upstream_response_time$request_time;access_loglogs/nginx/access.logmain;sendfileon;keepalive_timeout65;upstreamlocalhost{server127.0.0.1:80800max_fails=7fail_timeout=7s; } server{listen8080;server_namelocalhost;large_client_header_buffers4128k;client_max_body_size300m;client_body_buffer_size128k;proxy_connect_timeout600;proxy_read_timeout600;proxy_send_timeout600;proxy_buffer_size64k;proxy_buffers432k;proxy_busy_buffers_size64k;proxy_temp_file_write_size64k;#设定查看Nginx状态的地址 location/nginxstatus{stub_statuson;access_logon;auth_basicnginxstatus;auth_basic_user_filehtpasswd; }#ftpweb location/ftpweb{indexindex.htmlindex.htmindex.jsp;proxy_pass开放8089接口地址 location/interserver{indexindex.htmlindex.htmindex.jsp;proxy_pass这样就就可以一个nginx服务访问8080和8089两个端口到不同服务的了

  

注册即送1000元现金券