From 59dbd471af6b40e08be7c0c9b98109bb619a5ae0 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 14 Dec 2020 23:34:00 +0300 Subject: [PATCH] current state --- fastcgi-php.conf | 13 +++++++ fastcgi.conf | 29 +++++++++++++++ nginx.conf | 80 ++++++++++++++++++++++++++++++++++++++-- nginx.conf~ | 96 ++++++++++++++++++++++++++++++++++++++++++++++++ snakeoil.conf | 5 +++ 5 files changed, 220 insertions(+), 3 deletions(-) create mode 100644 fastcgi-php.conf create mode 100644 fastcgi.conf create mode 100644 nginx.conf~ create mode 100644 snakeoil.conf diff --git a/fastcgi-php.conf b/fastcgi-php.conf new file mode 100644 index 0000000..8f8e4a2 --- /dev/null +++ b/fastcgi-php.conf @@ -0,0 +1,13 @@ +# regex to split $uri to $fastcgi_script_name and $fastcgi_path +fastcgi_split_path_info ^(.+\.php)(/.+)$; + +# Check that the PHP script exists before passing it +try_files $fastcgi_script_name =404; + +# Bypass the fact that try_files resets $fastcgi_path_info +# see: http://trac.nginx.org/nginx/ticket/321 +set $path_info $fastcgi_path_info; +fastcgi_param PATH_INFO $path_info; + +fastcgi_index index.php; +include fastcgi.conf; diff --git a/fastcgi.conf b/fastcgi.conf new file mode 100644 index 0000000..04f0b7f --- /dev/null +++ b/fastcgi.conf @@ -0,0 +1,29 @@ + +fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +fastcgi_param QUERY_STRING $query_string; +fastcgi_param REQUEST_METHOD $request_method; +fastcgi_param CONTENT_TYPE $content_type; +fastcgi_param CONTENT_LENGTH $content_length; + +fastcgi_param SCRIPT_NAME $fastcgi_script_name; +fastcgi_param REQUEST_URI $request_uri; +fastcgi_param DOCUMENT_URI $document_uri; +fastcgi_param DOCUMENT_ROOT $document_root; +fastcgi_param SERVER_PROTOCOL $server_protocol; +fastcgi_param REQUEST_SCHEME $scheme; +fastcgi_param HTTPS $https if_not_empty; + +fastcgi_param GATEWAY_INTERFACE CGI/1.1; +fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; + +fastcgi_param REMOTE_ADDR $remote_addr; +fastcgi_param REMOTE_PORT $remote_port; +fastcgi_param SERVER_ADDR $server_addr; +fastcgi_param SERVER_PORT $server_port; +fastcgi_param SERVER_NAME $server_name; + +# PHP only, required if PHP was built with --enable-force-cgi-redirect +fastcgi_param REDIRECT_STATUS 200; + +fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +fastcgi_param PATH_INFO $fastcgi_script_name; diff --git a/nginx.conf b/nginx.conf index 06db783..19886d0 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,4 +1,4 @@ -worker_processes 1; +# xworker_processes 1; events { worker_connections 1024; @@ -12,10 +12,84 @@ http { sendfile on; keepalive_timeout 10; - server { + upstream backend { + server 89.223.91.151:8033; + } + + server { + listen 81; + server_name localhost; + root /home/ijl/ijl/apps/lavr/master; + + location / { + index index.html; + } + } + + server { + listen 82; + index index.php index.html index.htm index.nginx-debian.html; + server_name localhost; + root /home/ijl/ijl/apps/stc28; + + location / { + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + include fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + } + + location ~ /\.ht { + deny all; + } + } + + server { + listen 8079; + # index index.php index.html index.htm index.nginx-debian.html; + location / { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; + proxy_pass http://89.223.91.151:8080/; + } + + location /api { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; + proxy_pass http://backend; + } + } + + server { + listen 83; + root /home/ijl/; + index index.php index.html index.htm index.nginx-debian.html; + server_name localhost; + + location / { + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + include fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + } + + location ~ /\.ht { + deny all; + } + } + + server { listen 3002; server_name localhost; - set $udsRoot "/Users/teacher/teaching/2020/advance/project"; + set $udsRoot "/home/ijl/ijl/apps"; root $udsRoot; # index.html bootstrap diff --git a/nginx.conf~ b/nginx.conf~ new file mode 100644 index 0000000..00d9227 --- /dev/null +++ b/nginx.conf~ @@ -0,0 +1,96 @@ +# xworker_processes 1; + +events { + worker_connections 1024; +} + +http { + resolver 127.0.0.1; + include mime.types; + default_type application/octet-stream; + + sendfile on; + keepalive_timeout 10; + + server { + listen 81; + server_name localhost; + root /home/ijl/ijl/apps/lavr/master; + + location / { + index index.html; + } + } + + server { + listen 82; + index index.php index.html index.htm index.nginx-debian.html; + server_name localhost; + root /home/ijl/ijl/apps/stc28; + + location / { + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + include fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + } + + location ~ /\.ht { + deny all; + } + } + + server { + listen 83; + root /home/ijl/; + index index.php index.html index.htm index.nginx-debian.html; + server_name localhost; + + location / { + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + include fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + } + + location ~ /\.ht { + deny all; + } + } + + server { + listen 3002; + server_name localhost; + set $udsRoot "/home/ijl/ijl/apps"; + root $udsRoot; + + # index.html bootstrap + location / { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; + index index.html index.htm; + alias "$udsRoot/uds-middle/dist/"; + } + + # index.html bootstrap + location /static/ { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; + alias "$udsRoot/"; + # alias "$udsRoot/bootstrap/dist/index.js"; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } +} diff --git a/snakeoil.conf b/snakeoil.conf new file mode 100644 index 0000000..ad26c3e --- /dev/null +++ b/snakeoil.conf @@ -0,0 +1,5 @@ +# Self signed certificates generated by the ssl-cert package +# Don't use them in a production server! + +ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem; +ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;