You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 17, 2024. It is now read-only.
user www-data www-data;
worker_processes 5;
pid /var/run/nginx.pid;
worker_rlimit_nofile 1024;
# include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 512;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile off;
tcp_nopush on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
upstream default {
server app:9501 weight=1 max_fails=1 fail_timeout=10 ;
server app:81 backup;
# The connections parameter sets the maximum number of idle keepalive connections to upstream servers that are preserved in the cache of each worker process. When this number is exceeded, the least recently used connections are closed.
# It does not limit the total number of connections to upstream servers that an nginx worker process can open. The connections parameter should be set to a number small enough to let upstream servers process new incoming connections as well.
# https://gist.github.com/magnetikonline/4a2e68b2ce94bd0c945e
# https://ma.ttias.be/enable-keepalive-connections-in-nginx-upstream-proxy-configurations/
keepalive 8;
}
upstream swoole {
server app:9501;
}
upstream fpm {
server app:81;
}
# map to different upstream backends based on query parameter 'useserver'
# visit http://fly.test/?useserver=swoole to use server swoole
# visit http://fly.test to use upstream default
map $arg_useserver $pool {
default "default";
swoole "swoole";
fpm "fpm";
}
log_format my_upstream '$remote_addr|$time_local|$request_time|$upstream_response_time|$status '
'$upstream_addr|$request';
server {
server_name fly.test;
listen 80;
root /usr/share/nginx/html;
index index.html;
charset utf-8;
location = / {
# if you have a static home page , try this one:
# try_files index.html @other;
try_files '' @php;
}
location / {
try_files $uri $uri/ @php;
}
location @php {
proxy_pass http://$pool;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
# Remove the Connection header if the client sends it,
# it could be "close" to close a keepalive connection
proxy_set_header Connection "";
# proxy_connect_timeout 60s;
# proxy_send_timeout 60s;
# proxy_read_timeout 120s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
# proxy_set_header X-Real-PORT $remote_port;
# proxy_set_header Scheme $scheme;
# proxy_set_header Server-Protocol $server_protocol;
# proxy_set_header Server-Name $server_name;
# proxy_set_header Server-Addr $server_addr;
# proxy_set_header Server-Port $server_port;
# just a mark for different upstream server, you can disable it
add_header X-Upstream $upstream_addr;
# log
access_log /var/log/nginx/upstream.log my_upstream;
}
# # only for Let's Encrypt
# location ~ /.well-known {
# allow all;
# # set root is necessage, otherwise "Invalid response from domain..."
# # https://www.digitalocean.com/community/questions/letsencrypt-problem-renewing-certs-invalid-response-from-domain
# root {{ doc_root }};
# }
}
server {
server_name fly.test;
listen 81;
root /usr/share/nginx/html;
index index.html index.php;
charset utf-8;
location / {
try_files '' /index.php?$query_string;
}
location /index.php {
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
}
Swoole works well, but php-fpm always get 502 bad gateway
My docker-compose
My nginx app.conf
Swoole works well, but php-fpm always get 502 bad gateway