Skip to content

Instantly share code, notes, and snippets.

@fortl
Last active December 12, 2017 16:19
Show Gist options
  • Save fortl/7bb07905368dc7014848 to your computer and use it in GitHub Desktop.
Save fortl/7bb07905368dc7014848 to your computer and use it in GitHub Desktop.
Настройка локальной разработки
-----BEGIN CERTIFICATE-----
MIIDLjCCAhYCCQDBY/svIVKS+DANBgkqhkiG9w0BAQsFADBZMQswCQYDVQQGEwJS
VTEPMA0GA1UECAwGTW9zY293MQ8wDQYDVQQHDAZNb3Njb3cxDzANBgNVBAoMBlBs
dXJjaDEXMBUGA1UEAwwOZGV2LnBsdXJjaC5jb20wHhcNMTQxMjAzMTIwOTA3WhcN
MTUxMjAzMTIwOTA3WjBZMQswCQYDVQQGEwJSVTEPMA0GA1UECAwGTW9zY293MQ8w
DQYDVQQHDAZNb3Njb3cxDzANBgNVBAoMBlBsdXJjaDEXMBUGA1UEAwwOZGV2LnBs
dXJjaC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDgR92T9ShI
55/DfyRAIq39EcV6lWCZBG3nrgTSicE0t7RsSsyl4rzYgIUMchnpW/zEXnLKXy2w
ns7nGBfbkULxGxAN+OJN4qqYPySUig56SWr33mKpiaC7KIJj6o4Jidg4LWpMo8ca
DKV50eGe1TYOFn39u+GGESnLqEAnnSZAY+orO9cVTvljP/KxzzmNTK7BErn2sezU
YFWDHHBZ7Rfd6gqkiPFKFbuhShWkt4wm7flIAuWlBDoKYPzG1MX+n8HKc7nCZQbW
8eT7h4Q04qCoGniBxt5szgaLsrWXQk0VzW3rBARwG8OzX/8w61+5exDmzP1IdZyy
8B/5OVHoOpQ3AgMBAAEwDQYJKoZIhvcNAQELBQADggEBAMBmFLak2WFws19vJvEe
M+jcpBc7k3JpsKrXT+NvbV5FLfALKdZ2B9r4IInqVc+ASXMiVGhIww3ISyVqBClg
ZTwLies2cuIQFQuPpscOwJ/r7K0XSs0qPgfWRvfb5clk9ndXmL4tVz/sms5F8B2M
G8Of+eTbugj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1C+xo2qyMDcbodYbNNHpxSENLWEKBxNjzjdXTw4blPBH6sUecCgYEA6INo
D7Wpvbq3r3+3KPIxYbDU5bEv3Kjq5hEem9OgUkmhmFmxjMUhOO5ckDw5OvlK2+HU
8ZtooNfP+VflUW5ZN/Z8WM4d5o7MHwUm8LN2A0dhevwR/NffP0VHg/KwJj2B38R0
pIVlzq0hMSYxMHRSQdoB1GDAKCMJAnojdcgLATECgYBFizkBh3qKnlglVJjb3Dsn
LM5YE1YkaCC4CHTrQCjXmooLC5xba2Teq4Ga6fLf9nDQFnKPdba8l3+z1z2LQrcu
/pNBhRkRxARgKEnsaqgZfQB3/S2v/a6pGVuFaZYok7xbvDOnHsxRjKamfU3bcRVa
f2UC6mkA1ltUptSrJmWvdwKBgQC1UJO7fGxrecl3395S3drIVX8PxwaNymOzGTKH
TZY91RFgnsEoBymLHcWs7GmspW5M3WSTLB+BHgoeZP58a9LDI0GAdus2ObDPl9Lv
7OJgWC+aGitkwmpjCoFkUcIvb9NxTd+v1B659qRlkWTWZj8m/vxiQzhVlEyYU+qH
FIIQYQKBgGr6d+aGClY6FmpDMPPvD5EVqBJgzTkufiiptB5RRVzV0vVa6JYn0V1x
jwc85mZrBVk1Kjwcztcuysafk4CQCgvR588ADhdwW/upxFE1Ctln4OHqt+2ToFw8
qHk66FdIM9GNSItNlyGQcAONi/Jp71418NFbRIdBt6VGaeMHL8E9
-----END RSA PRIVATE KEY-----
server {
listen 80;
listen 443 ssl;
client_body_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
send_timeout 300s;
ssl_certificate /Users/bashmish/Projects/timedesigner/td.crt;
ssl_certificate_key /Users/bashmish/Projects/timedesigner/td.key;
server_name dev.mb.dev.plurch.com;
access_log /var/log/nginx/timedesigner.access.log main;
error_log /var/log/nginx/timedesigner.error.log;
client_max_body_size 60m;
root /Users/bashmish/Projects/timedesigner/tdfront/public/files;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-HTTPS $http_https;
location = /cache.appcache {
expires -1;
default_type text/cache-manifest;
}
# ugly hack, better move assets to separate domain
location ~ /(css|fonts|i|j)/ {
expires -1;
add_header Cache-Control public;
access_log /var/log/nginx/timedesigner-assets.access.log main;
}
location /api/ {
proxy_pass http://mb.dev.plurch.com;
# !!!! вместо <base64 user:passwd> надо подставить закодированные в base64 свои логин:пароль
proxy_set_header Authorization "Basic <base64 user:passwd>";
access_log /var/log/nginx/timedesigner-api.access.log main;
}
location / {
try_files /root/$uri $uri $uri/index.html /index.html;
}
}
server {
listen localhost:80;
listen localhost:443 ssl;
server_name sr.dev.time.sc *.sr.dev.time.sc;
root /opt/sr/public/files;
access_log /var/log/nginx/sr.access.log main;
error_log /var/log/nginx/sr.error.log debug;
client_max_body_size 60m;
ssl_certificate keys/sr.dev.time.sc.crt;
ssl_certificate_key keys/sr.dev.time.sc.key;
location /favicon.ico {
default_type image/x-icon;
alias /home/nilagor/frontend/public/files/i/favicon.ico;
}
######Proxy headers
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-HTTPS $http_https;
location /cache.appcache {
open_file_cache off;
open_file_cache_errors off;
expires -1;
default_type text/cache-manifest;
# access_log logs/static.log; # I don't usually include a static log
}
include /etc/nginx/common-options;
location ~ /(css|fonts|i|j|files)/ {
open_file_cache off;
open_file_cache_errors off;
expires -1;
add_header Cache-Control public;
}
location / {
try_files /root$uri $uri @backend;
}
location @backend {
internal;
proxy_pass http://localhost:6003;
access_log /nginx/logs/server.access.log main;
# !!!! вместо <base64 user:passwd> надо подставить закодированные в base64 свои логин:пароль
proxy_set_header Authorization "Basic <base64 user:password>";
}
}
user root wheel;
worker_processes 1;
error_log /nginx/logs/error.log;
error_log /nginx/logs/error.log notice;
error_log /nginx/logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /nginx/logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
client_body_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
send_timeout 300s;
gzip on;
server {
listen 80;
listen 443 ssl;
ssl_certificate /nginx/keys/dev.plurch.com.crt;
ssl_certificate_key /nginx/keys/dev.plurch.com.key;
server_name localhost;
root /workspace/plurch-front/public;
access_log /nginx/logs/timedesigner.access.log main;
error_log /nginx/logs/timedesigner.error.log;
client_max_body_size 60m;
######Proxy headers
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-HTTPS $http_https;
location /cache.appcache {
open_file_cache off;
open_file_cache_errors off;
expires -1;
default_type text/cache-manifest;
# access_log logs/static.log; # I don't usually include a static log
}
location = /cache.appcache {
expires -1;
default_type text/cache-manifest;
}
location ~ /(css|fonts|i|j)/ {
expires -1;
add_header Cache-Control public;
access_log /var/log/nginx/timedesigner-assets.access.log main;
open_file_cache off;
}
location /api/ {
proxy_pass http://au.dev.plurch.com;
access_log /nginx/logs/server.access.log main;
# !!!! вместо <base64 user:passwd> надо подставить закодированные в base64 свои логин:пароль
proxy_set_header Authorization "Basic <base64 user:password>";
}
location / {
try_files /root/$uri $uri $uri/index.html /index.html;
}
}
}
Как запустить Nginx под windows:
http://misterdai.yougeezer.co.uk/posts/2009/10/16/nginx-windows-service/
1. качаем нгинкс: http://nginx.org/en/docs/windows.html
распаковываем в c:/nginx
2. качаем http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/
копируем в c:/nginx
переименовываем в nginx-sw.exe
3. создаем конфиг сервиса c:/nginx/nginx-sw.xml
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<executable>c:\nginx\nginx.exe</executable>
<logpath>c:\nginx\</logpath>
<logmode>roll</logmode>
<depend></depend>
<startargument>-pc:\nginx</startargument>
<stopargument>-pc:\nginx -s stop</stopargument>
</service>
4. выключаем бинд на 80 порт у skype:
http://take.ms/0Jlij
5.
редактируем c:/nginx/conf/nginx.conf
(см. ниже, пути к локальным файлам и пароль в base64 правим сами)
6. запустить консоль от имени администратора
http://take.ms/SoOW2
7.
cd /nginx
nginx-sw install
nginx-sw start
8.
должны появиться логи запуска c:/nginx/nginx-sw.err.log /nginx-sw.out.log
смотрим nginx-sw.err.log на наличие ошибок (fatal\emerg)
9. делаем запрос к http://localhost/
если есть проблемы, смотрим наличие ошибок в c:/nginx/logs/*
10. кладем файлы dev.plurch.com.key/dev.plurch.com.crt в /nginx/keys
перезапускаем сервер, проверяем https
(вариант - можно выписать валидные сертификаты, чтобы не выскакивала ошибка, за этим - к админам)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment