채택완료
ngnix + php-fpm 에서 SSE 오류로 ngnix.conf 내용을 어떻게 수정해야 되나요?
제 ngnix.conf 파일 내용은 아래와 같습니다.
listen [::]:80;
listen 443 quic;
listen 443 ssl;
listen [::]:443 quic;
listen [::]:443 ssl;
http2 on;
http3 off;
{{ssl_certificate_key}}
{{ssl_certificate}}
server_name www.inyourtalk.com;
return 301 https://inyourtalk.com$request_uri;
}
server {
listen 80;
listen [::]:80;
listen 443 quic;
listen 443 ssl;
listen [::]:443 quic;
listen [::]:443 ssl;
http2 on;
http3 off;
{{ssl_certificate_key}}
{{ssl_certificate}}
server_name inyourtalk.com www1.inyourtalk.com;
{{root}}
{{nginx_access_log}}
{{nginx_error_log}}
if ($scheme != "https") {
rewrite ^ https://$host$request_uri permanent;
}
location ~ /.well-known {
auth_basic off;
allow all;
}
{{settings}}
location / {
{{varnish_proxy_pass}}
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Varnish;
proxy_redirect off;
proxy_max_temp_file_size 0;
proxy_connect_timeout 720;
proxy_send_timeout 720;
proxy_read_timeout 720;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
}
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map|mjs)$ {
add_header Access-Control-Allow-Origin "*";
add_header alt-svc 'h3=":443"; ma=86400';
expires max;
access_log off;
}
location ~ /\.(ht|svn|git) {
deny all;
}
if (-f $request_filename) {
break;
}
}
server {
listen 8080;
listen [::]:8080;
server_name inyourtalk.com www1.inyourtalk.com;
{{root}}
include /etc/nginx/global_settings;
try_files $uri $uri/ /index.php?$args;
index index.php index.html;
location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404;
fastcgi_read_timeout 3600;
fastcgi_send_timeout 3600;
fastcgi_param HTTPS "on";
fastcgi_param SERVER_PORT 443;
fastcgi_pass 127.0.0.1:{{php_fpm_port}};
fastcgi_param PHP_VALUE "{{php_settings}}";
}
if (-f $request_filename) {
break;
}
}
그누보드7 설치 마지막에 SSE 오류로 아래와 같이 적용 하라는데
install-worker.php 파일 상단에는 아래의 내용을 추가했는데 nginx.conf 파일에는 어떻게 적용을 해야되나요?
아래 부분을 위의 파일 내용에 추가를 했는데도 계속 오류가 뜨니 정확하게 작성하는 방법이 궁금합니다.
그리고 포트 8080은 방화벽 설정에서 제외를 시켜야 하는 것인가요?
server {
listen 80;listen [::]:80;
listen 443 quic;
listen 443 ssl;
listen [::]:443 quic;
listen [::]:443 ssl;
http2 on;
http3 off;
{{ssl_certificate_key}}
{{ssl_certificate}}
server_name www.inyourtalk.com;
return 301 https://inyourtalk.com$request_uri;
}
server {
listen 80;
listen [::]:80;
listen 443 quic;
listen 443 ssl;
listen [::]:443 quic;
listen [::]:443 ssl;
http2 on;
http3 off;
{{ssl_certificate_key}}
{{ssl_certificate}}
server_name inyourtalk.com www1.inyourtalk.com;
{{root}}
{{nginx_access_log}}
{{nginx_error_log}}
if ($scheme != "https") {
rewrite ^ https://$host$request_uri permanent;
}
location ~ /.well-known {
auth_basic off;
allow all;
}
{{settings}}
location / {
{{varnish_proxy_pass}}
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Varnish;
proxy_redirect off;
proxy_max_temp_file_size 0;
proxy_connect_timeout 720;
proxy_send_timeout 720;
proxy_read_timeout 720;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
}
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map|mjs)$ {
add_header Access-Control-Allow-Origin "*";
add_header alt-svc 'h3=":443"; ma=86400';
expires max;
access_log off;
}
location ~ /\.(ht|svn|git) {
deny all;
}
if (-f $request_filename) {
break;
}
}
server {
listen 8080;
listen [::]:8080;
server_name inyourtalk.com www1.inyourtalk.com;
{{root}}
include /etc/nginx/global_settings;
try_files $uri $uri/ /index.php?$args;
index index.php index.html;
location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404;
fastcgi_read_timeout 3600;
fastcgi_send_timeout 3600;
fastcgi_param HTTPS "on";
fastcgi_param SERVER_PORT 443;
fastcgi_pass 127.0.0.1:{{php_fpm_port}};
fastcgi_param PHP_VALUE "{{php_settings}}";
}
if (-f $request_filename) {
break;
}
}
그누보드7 설치 마지막에 SSE 오류로 아래와 같이 적용 하라는데
install-worker.php 파일 상단에는 아래의 내용을 추가했는데 nginx.conf 파일에는 어떻게 적용을 해야되나요?
아래 부분을 위의 파일 내용에 추가를 했는데도 계속 오류가 뜨니 정확하게 작성하는 방법이 궁금합니다.
그리고 포트 8080은 방화벽 설정에서 제외를 시켜야 하는 것인가요?
[Nginx 설정]
location /install/api/ {
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 600s;
}
[Apache 설정]
# .htaccess 또는 httpd.conf
<Location /install/api/>
SetEnv no-gzip 1
</Location>
[PHP 설정]
// install-worker.php 최상단에 추가
ini_set('output_buffering', 'off');
ini_set('zlib.output_compression', 'off');
@apache_setenv('no-gzip', 1);
|
답변 2개 / 댓글 2개
채택된 답변
+20 포인트
지금 구성에서는 /install/api/ 요청도 location /를 타기 때문에 SSE가 깨질 수 있습니다.
443 server 블록에서 location / 위에 /install/api/ 전용 location을 추가하고 proxy_buffering off를 적용하시면 됩니다.
또한 8080의 PHP location에는 fastcgi_buffering off 한 줄만 추가해도 충분합니다.
8080 포트는 내부 전달이라 외부 접근(방화벽) 관련 설정은 필요없습니다.
전체적으로 보면 설정이 다소 과한 편이고, 최소 수정만으로도 충분합니다.
Copy
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
{{ssl_certificate_key}}
{{ssl_certificate}}
server_name www.inyourtalk.com;
return 301 https://inyourtalk.com$request_uri;
}
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
{{ssl_certificate_key}}
{{ssl_certificate}}
server_name inyourtalk.com www1.inyourtalk.com;
{{root}}
{{nginx_access_log}}
{{nginx_error_log}}
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
location ^~ /.well-known/ {
auth_basic off;
allow all;
}
{{settings}}
location ^~ /install/api/ {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
proxy_read_timeout 600s;
}
location / {
{{varnish_proxy_pass}}
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Varnish;
proxy_redirect off;
proxy_connect_timeout 720;
proxy_send_timeout 720;
proxy_read_timeout 720;
}
location ~* \.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map|mjs)$ {
add_header Access-Control-Allow-Origin "*";
expires max;
access_log off;
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
server {
listen 8080;
listen [::]:8080;
server_name inyourtalk.com www1.inyourtalk.com;
{{root}}
include /etc/nginx/global_settings;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_buffering off;
fastcgi_pass 127.0.0.1:{{php_fpm_port}};
fastcgi_param PHP_VALUE "{{php_settings}}";
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
답변에 대한 댓글 1개
우리 동굴님 아직도 ~~
딱보니 server {} 여기 블록안이 복잡하게 잘못처리된 것 으로 보이네요
먼저 80 443 ssl 포트 부터 통합 정의하세요
그리고
블록를 보시면 {{root}} 이부분 실제 경로 지정을해주셔야합니다.
root /실제 설치 경로 ;
그리고
기본디폴트 인덱스 설정된부분 아래에다 SSE용 API 경로 지정해보시기 바랍니다.
location /install/api/ {
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 600s;
fastcgi_buffering off;
}
또그리고 제일아래 아피치 웹서버에서는 조건쓰는게 맞지만 Nginx에서는 if 지시어를사용을 권장하지않습니다.
하여 아래 부분 지워버리시기 바랍니다.
if (-f $request_filename) {
break;
}
root /실제 설치 경로 ; 아래에 try_files $uri $uri/ /index.php?$args; 이렇게 넣어주세요
참고로 아파치서버만 htaccess 지원하지 Nginx서버에서는 지원하지 않는 다라는점 참고하시기 바랍니다.
딱보니 server {} 여기 블록안이 복잡하게 잘못처리된 것 으로 보이네요
먼저 80 443 ssl 포트 부터 통합 정의하세요
그리고
블록를 보시면 {{root}} 이부분 실제 경로 지정을해주셔야합니다.
root /실제 설치 경로 ;
그리고
기본디폴트 인덱스 설정된부분 아래에다 SSE용 API 경로 지정해보시기 바랍니다.
location /install/api/ {
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 600s;
fastcgi_buffering off;
}
또그리고 제일아래 아피치 웹서버에서는 조건쓰는게 맞지만 Nginx에서는 if 지시어를사용을 권장하지않습니다.
하여 아래 부분 지워버리시기 바랍니다.
if (-f $request_filename) {
break;
}
root /실제 설치 경로 ; 아래에 try_files $uri $uri/ /index.php?$args; 이렇게 넣어주세요
참고로 아파치서버만 htaccess 지원하지 Nginx서버에서는 지원하지 않는 다라는점 참고하시기 바랍니다.
답변에 대한 댓글 1개
답변을 작성하려면 로그인이 필요합니다.