【求助】我在做一个网站,nginx配置并不生效

向小伙伴们求助:
Nginx好像是不生效,昨天折腾到三点多,还是没弄好。

前后端应用,我先指望前端生效。

域名为 fccareer.top,在cloudflare管理,配置了DNS解析:


应用使用pm2启动,可以通过IP+端口号正常调用。
如下:
FIFA Career Dashboard
FIFA Career Dashboard Backend

Nginx 配置却死活不行,怎么访问都是返回默认的页面 Test Page for the Nginx HTTP Server on Oracle Linux (app.fccareer.top)

这是我的Nginx配置:

#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"'
                      'Server: $host';


    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;

    keepalive_timeout  65;

    #gzip  on;

    # 前端应用
    server {
        listen 443 ssl; # managed by Certbot
        server_name app.fccareer.top;
        location / {
            proxy_pass http://localhost:3001;  # 前端应用的端口
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        ssl_certificate /etc/letsencrypt/live/fccareer.top/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/fccareer.top/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    }


    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

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

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

}

请问这是为何,以上地址均可访问。向L佬们求助,感激~

1 Like

#快问快答添加

80没配置啊。cf 的 ssl 里配置一下完全试试

2 Likes

竟然是始皇。 :blush:

80配置是不是下面的那一段,应该是配置了?
ssl配置我试试,感谢!

关掉 ssl 配置就行了
image
这边改成 80 的那种

卧槽牛逼,可以了!!!

FIFA Career Dashboard (fccareer.top)

但。。。。这个是什么原理,这么神奇。?

哎呀,我就是想配置成https的呀,这个关了岂不是不是https的了

cf 自带 https https://v7.al

啊,就是我不需要申请证书了? :slightly_smiling_face:

默认ssl级别,会员到80。而你80其实没有配置

1 Like

image

1 Like

用cf的服务器证书回源即可,15年有效期。可以开完全。

1 Like

80回源,如果你服务器跟cf中间网络有中间人,就全漏了。

2 Likes

在此统一感谢大佬们,信息量有点多,新知识有点多,我需要消化一下…
我的问题已经解决,我后续再做更多探索。
十分感谢~

1 Like