File tree Expand file tree Collapse file tree 7 files changed +88
-4
lines changed Expand file tree Collapse file tree 7 files changed +88
-4
lines changed Original file line number Diff line number Diff line change @@ -7,4 +7,9 @@ MYSQL_ROOT_HOST=%
7
7
MYSQL_ROOT_PASSWORD = hSMZYpAGbNwVmERI
8
8
9
9
# hyperf
10
- HYPERF = ./hyperf
10
+ HYPERF_DIR = ./hyperf
11
+
12
+ # nginx
13
+ NGINX_DIR = ./nginx
14
+ HTTP_PORT = 80
15
+ HTTPS_PORT = 443
Original file line number Diff line number Diff line change @@ -7,4 +7,9 @@ MYSQL_ROOT_HOST=%
7
7
MYSQL_ROOT_PASSWORD = hSMZYpAGbNwVmERI
8
8
9
9
# hyperf
10
- HYPERF = ./hyperf
10
+ HYPERF_DIR = ./hyperf
11
+
12
+ # nginx
13
+ NGINX_DIR = ./nginx
14
+ HTTP_PORT = 80
15
+ HTTPS_PORT = 443
Original file line number Diff line number Diff line change @@ -5,6 +5,22 @@ networks:
5
5
driver : bridge
6
6
7
7
services :
8
+ nginx :
9
+ image : nginx:alpine
10
+ container_name : hyper_nginx
11
+ ports :
12
+ - " ${HTTP_PORT}:80"
13
+ - " ${HTTPS_PORT}:443"
14
+ volumes :
15
+ - ./hyperf:/etc/nginx/www/hyperf:rw
16
+ - ${NGINX_DIR}/config/nginx.conf:/etc/nginx/nginx.conf:ro
17
+ - ${NGINX_DIR}/config/conf.d:/etc/nginx/conf.d:ro
18
+ - ${NGINX_DIR}/log:/var/log/nginx:rw
19
+ restart : always
20
+ networks :
21
+ - hyperf
22
+ tty : true
23
+
8
24
redis :
9
25
container_name : hyper_redis
10
26
image : redis:latest
@@ -49,7 +65,7 @@ services:
49
65
container_name : hyperf
50
66
image : hyperf/hyperf:latest
51
67
volumes :
52
- - .:/opt/www
68
+ - ./hyperf :/opt/www/hyperf
53
69
ports :
54
70
- " 9501:9501"
55
71
- " 9502:9502"
Original file line number Diff line number Diff line change 3
3
declare (strict_types=1 );
4
4
namespace App \Model ;
5
5
6
- use Hyperf \DbConnection \Model \Model ;
7
6
/**
8
7
* @property int $id
9
8
* @property string $username
Original file line number Diff line number Diff line change
1
+ /log
Original file line number Diff line number Diff line change
1
+ # 至少需要一个 Hyperf 节点,多个配置多行
2
+ upstream hyperf {
3
+ # Hyperf HTTP Server 的 IP 及 端口
4
+ server hyperf:9501;
5
+ server hyperf:9502;
6
+ }
7
+
8
+ server {
9
+ # 监听端口
10
+ listen 80;
11
+ # 绑定的域名,填写您的域名
12
+ server_name basic.com;
13
+
14
+ location / {
15
+ # 将客户端的 Host 和 IP 信息一并转发到对应节点
16
+ proxy_set_header Host $http_host;
17
+ proxy_set_header X-Real-IP $remote_addr;
18
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19
+
20
+ # 转发Cookie,设置 SameSite
21
+ proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict";
22
+
23
+ # 执行代理访问真实服务器
24
+ proxy_pass http://hyperf;
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+
2
+ user nginx;
3
+ worker_processes 1 ;
4
+
5
+ pid /var/run/nginx.pid;
6
+ error_log /var/log/nginx/error.log warn ;
7
+
8
+ events {
9
+ worker_connections 1024 ;
10
+ }
11
+
12
+
13
+ http {
14
+ include /etc/nginx/mime.types;
15
+ default_type application/octet-stream;
16
+
17
+ log_format main '$remote_addr - $remote_user [$time_local ] "$request " '
18
+ '$status $body_bytes_sent "$http_referer " '
19
+ '"$http_user_agent " "$http_x_forwarded_for "' ;
20
+
21
+ access_log /dev/null;
22
+ #access_log /var/log/nginx/access.log main;
23
+
24
+ sendfile on ;
25
+ #tcp_nopush on;
26
+
27
+ keepalive_timeout 65 ;
28
+
29
+ #gzip on;
30
+
31
+ include /etc/nginx/conf.d/*.conf;
32
+ }
You can’t perform that action at this time.
0 commit comments