Closed car520120 closed 1 year ago
我使用 gentoo 发行版来的,主要是用来学习的 因为使用默认安装就是 PHP8 MYSQL8 来的 composer 我忽略了版本差异是可以安装好的 nginx 是自己编译的,主要用于 webdav nextcloud 等等一些服务上 现在想试一下你这个功能,发现不太会配置,不知道能不能教一下?谢谢的了
user admin; worker_processes 4; pid /var/run/nginx.pid; events { use epoll; worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; gzip on; dav_ext_lock_zone zone=davlock:10m; include /opt/local/nginx/conf/www.d/*.conf; }
server { listen 8001; #listen 443 ssl; #ssl_certificate <your_ssl_cert>.crt; #ssl_certificate_key <your_ssl_cert_private_key>.key; #ssl_session_cache shared:SSL:1m; #ssl_session_timeout 5m; #ssl_ciphers HIGH:!aNULL:!MD5; #ssl_prefer_server_ciphers on; server_name localhost; root /data/www/codefever-community/www/; access_log /var/log/nginx/codefever/access_8001.log; error_log /var/log/nginx/codefever/error_8001.log; location ~* ^\/[0-9a-z_]+\/[0-9a-z_]+\.git { proxy_pass http://127.0.0.1:27555; } location ^~ /static/ { rewrite "(.*)\.map(.*)" "/static/not/found" last; rewrite "^/static/\d{14}/(.*)$" "/static/$1" last; try_files $uri /app$uri 404; } location ~* ^/(user|file|feature|doc|community|lang|captcha|boss|service|pricing|api(v\d+)?)?(\/.*)?$ { try_files $uri $uri/ /index.php; } location / { try_files $uri /app/index.html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param ENVIRONMENT "production"; include fastcgi_params; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; fastcgi_read_timeout 300s; } } server { listen 8001; #listen 443 ssl; #ssl_certificate <your_ssl_cert>.crt; #ssl_certificate_key <your_ssl_cert_private_key>.key; #ssl_session_cache shared:SSL:1m; #ssl_session_timeout 5m; #ssl_ciphers HIGH:!aNULL:!MD5; #ssl_prefer_server_ciphers on; server_name localhost-dev; root /data/www/codefever-community/www/; access_log /var/log/nginx/codefever/access_8001.log; error_log /var/log/nginx/codefever/error_8001.log; location ~* ^\/[0-9a-z_]+\/[0-9a-z_]+\.git { proxy_pass http://127.0.0.1:27555; } location ^~ /sockjs-node { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location ^~ /__webpack_dev_server__/ { proxy_pass http://127.0.0.1:3000; } location ~ ^/static/\d+/ { proxy_pass http://localhost; } location ~* ^/(user|file|feature|doc|community|lang|captcha|boss|service|pricing|api(v\d+)?)?(\/.*)?$ { proxy_pass http://localhost; } location / { proxy_pass http://127.0.0.1:3000; } }
访问 http://192.168.3.50:8001/ 报错如下 File not found.
2022/11/26 12:40:28 [error] 8116#0: *34 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.3.22, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.3.50:8001" 2022/11/26 12:40:28 [error] 8116#0: *34 rewrite or internal redirection cycle while internally redirecting to "/app/index.html", client: 192.168.3.22, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.3.50:8001", referrer: "http://192.168.3.50:8001/"
@car520120 很抱歉这么晚回复你, nginx 出现 File Not Found 的问题,应该是配置问题。看了你的配置,并没有指定 index 的配置。 你可以在 http 配置段 或者 server 配置段里面加上 index 配置,例如:
nginx
File Not Found
index
http
server
index index.php index.html index.htm;
设置完以后重启您的 nginx 服务器。然后看看有没有改善。
我使用 gentoo 发行版来的,主要是用来学习的 因为使用默认安装就是 PHP8 MYSQL8 来的 composer 我忽略了版本差异是可以安装好的 nginx 是自己编译的,主要用于 webdav nextcloud 等等一些服务上 现在想试一下你这个功能,发现不太会配置,不知道能不能教一下?谢谢的了
访问 http://192.168.3.50:8001/ 报错如下 File not found.