zipusyan commited on
Commit
5dab012
·
verified ·
1 Parent(s): 47ec002

Update nginx.conf

Browse files
Files changed (1) hide show
  1. nginx.conf +52 -33
nginx.conf CHANGED
@@ -1,37 +1,56 @@
1
- server {
2
- listen 8088;
3
- server_name localhost;
4
-
5
- # PHP Website
6
- root /home/www;
7
- index index.php index.html;
8
-
9
- location / {
10
- # 1. Try requested file ($uri)
11
- # 2. Try requested directory ($uri/)
12
- # 3. If neither exists, fallback to OpenCode proxy (@opencode)
13
- try_files $uri $uri/ @opencode;
14
- }
15
 
16
- # PHP execution logic
17
- location ~ \.php$ {
18
- # Only execute PHP if the file exists on disk
19
- try_files $uri =404;
20
- include snippets/fastcgi-php.conf;
21
- fastcgi_pass unix:/run/php/php7.4-fpm.sock;
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- # Fallback Proxy for OpenCode Web and its static assets
25
- location @opencode {
26
- proxy_pass http://127.0.0.1:8080;
27
- proxy_set_header Host $host;
28
- proxy_set_header X-Real-IP $remote_addr;
29
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
30
- proxy_set_header X-Forwarded-Proto $scheme;
31
-
32
- # WebSocket support for OpenCode
33
- proxy_http_version 1.1;
34
- proxy_set_header Upgrade $http_upgrade;
35
- proxy_set_header Connection "upgrade";
36
  }
37
  }
 
1
+ # 运行为 root 用户
2
+ user root;
3
+ worker_processes auto;
4
+ pid /run/nginx.pid;
 
 
 
 
 
 
 
 
 
 
5
 
6
+ events {
7
+ worker_connections 768;
8
+ }
9
+
10
+ http {
11
+ sendfile on;
12
+ tcp_nopush on;
13
+ tcp_nodelay on;
14
+ keepalive_timeout 65;
15
+ types_hash_max_size 2048;
16
+ include /etc/nginx/mime.types;
17
+ default_type application/octet-stream;
18
+
19
+ # 必要的目录配置
20
+ client_body_temp_path /tmp/nginx_body 1 2;
21
+ proxy_temp_path /tmp/nginx_proxy;
22
+ fastcgi_temp_path /tmp/nginx_fastcgi;
23
+
24
+ access_log /var/log/nginx/access.log;
25
+ error_log /var/log/nginx/error.log;
26
+
27
+ server {
28
+ listen 80;
29
+ server_name localhost;
30
+
31
+ root /home/www;
32
+ index index.php index.html;
33
+
34
+ location / {
35
+ try_files $uri $uri/ @opencode;
36
+ }
37
+
38
+ location ~ \.php$ {
39
+ try_files $uri =404;
40
+ include fastcgi_params;
41
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
42
+ fastcgi_pass unix:/run/php/php7.4-fpm.sock;
43
+ }
44
 
45
+ location @opencode {
46
+ proxy_pass http://127.0.0.1:8080;
47
+ proxy_set_header Host $host;
48
+ proxy_set_header X-Real-IP $remote_addr;
49
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
50
+
51
+ proxy_http_version 1.1;
52
+ proxy_set_header Upgrade $http_upgrade;
53
+ proxy_set_header Connection "upgrade";
54
+ }
 
 
55
  }
56
  }