nginx配置问题

默认下载了nginx打开配置文件

配置说明:默认下载的配置需要手动设置一下刷新404和代理问题

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

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #说明静态资源访问的是html文件夹下面的资源
            root   html;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html; #解决刷新404

        }
        location /dev/ {
            #设置代理目标
            proxy_pass http://www.xxxxxxxxxxx
        }


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

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
配置Nginx时,常见的问题和解决方法如下: 1. 错误的配置语法:Nginx配置文件使用特定的语法,如果配置文件中存在语法错误,Nginx将无法启动或者无法加载配置。解决方法是检查配置文件中的语法错误,并使用`nginx -t`命令进行语法检查。 2. 端口冲突:如果Nginx监听的端口与其他应用程序监听的端口冲突,Nginx将无法启动。解决方法是修改Nginx配置文件中的端口号,确保与其他应用程序没有冲突。 3. 无法访问静态文件:如果配置了静态文件的路径,但是无法通过Nginx访问这些文件,可能是由于权限问题或者路径配置错误。解决方法是确保文件路径正确,并检查文件权限是否允许Nginx访问。 4. 代理设置错误:如果配置了代理服务器,但是无法正确转发请求给目标服务器,可能是由于代理设置错误。解决方法是检查代理设置是否正确,并确保目标服务器可以正常访问。 5. SSL证书配置问题:如果配置了SSL证书,但是无法正确启用HTTPS访问,可能是由于证书配置错误。解决方法是检查证书路径和权限,并确保证书文件正确配置。 6. 负载均衡问题:如果配置了负载均衡,但是请求没有被正确分发给后端服务器,可能是由于负载均衡配置错误。解决方法是检查负载均衡配置,确保后端服务器的健康检查和权重配置正确。 7. 缓存配置问题:如果配置了缓存,但是无法正确缓存响应,可能是由于缓存配置错误。解决方法是检查缓存配置,并确保响应的缓存策略和过期时间正确设置。 以上是一些常见的Nginx配置问题及其解决方法,根据具体情况进行排查和调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

库库的写代码

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值