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;
 
  #服务器的集群  
  upstream  mySite.com { #服务器集群名字   
  server 192.168.1.101:8080 weight=1;#服务器配置 weight是权重的意思,权重越大,分配的概率越大。  
  server 192.168.1.102:8080 weight=1;  
  }
 
  server {
  listen 80;
  server_name localhost;
 
  #charset koi8-r;
 
  #access_log logs/host.access.log main;
 
  location / {
  proxy_pass http://mySite.com;  
  proxy_redirect default;
  }
 
  #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;
  # }
  #}
 
}
 

转载于:https://www.cnblogs.com/gdufs/p/6432283.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Nginx配置文件中,通常会使用conf.d目录来存放额外的配置文件。具体操作如下: 1. 打开/etc/nginx/conf.d/文件夹。 2. 在该文件夹下创建一个新的配置文件,例如xxx.conf。 3. 在新的配置文件中,可以按照需求添加服务器的配置信息。 4. 例如,可以在配置文件中设置监听端口和服务器名称: ``` server { listen 80; server_name **.106.2**.175; ... } ``` 5. 可以在配置文件中使用location指令来指定不同路径的处理方式,例如: ``` location / { root /public/app/dist; index index.php index.html index.htm; ... } location /sell { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:8080; proxy_redirect off; ... } ``` 6. 配置完成后,可以通过重新启动或重载Nginx来使配置生效,例如: ``` nginx -t # 查看Nginx状态 nginx -s reload # 重新载入配置文件 nginx -s reopen # 重启Nginx nginx -s stop # 停止Nginx ``` 这样,通过在conf.d目录下创建配置文件,并在其中添加相应的配置信息,可以对Nginx进行灵活的配置和管理。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [Nginx配置使用实例分析](https://blog.csdn.net/qq_39162487/article/details/125547870)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值