Last active
February 25, 2020 16:05
-
-
Save MostafaEzzelden/24515e3c7bd07742d9bfac6987dc5472 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
# Redirect To HTTPS | |
server { | |
listen 80 default_server; | |
server_name _; | |
return 301 https://$server_name$request_uri; | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
root /var/www/html; | |
server_name _; | |
index index.php index.html; | |
location / { | |
try_files $uri $uri/ index.php$is_args$args; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/run/php/php7.2-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
location /socket { | |
try_files /not_exist @swoole; | |
} | |
location @swoole { | |
set $suffix ""; | |
if ($uri = /index.php) { | |
set $suffix ?$query_string; | |
} | |
proxy_set_header Host $http_host; | |
proxy_set_header Scheme $scheme; | |
proxy_set_header SERVER_PORT $server_port; | |
proxy_set_header REMOTE_ADDR $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
proxy_set_header HTTPS "on"; | |
charset utf-8; | |
proxy_pass http://127.0.0.1:1216$suffix; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment