Categories
- FFMpeg (5)
- Libav (1)
- Google (3)
- iBeacon (1)
- LDAP (3)
- Me (2)
- Network (11)
- OS (149)
- RTMP (4)
- SIP (1)
- Kamailio (1)
- SNMP (1)
- VMware (20)
- VCP考試 (1)
- 伺服器 網站服務 (105)
- 名詞解釋 (4)
- 專案管理 (1)
- 工具軟體 (50)
- Adobe (1)
- FMS (1)
- Cloudera (1)
- Docker (1)
- Eclipse (4)
- Intellij (2)
- OBS (2)
- Office (10)
- Excel (4)
- PowerPoint (5)
- Postman (1)
- Splunk (13)
- Virtualbox (2)
- Visual Studio (2)
- 文字編輯器 (10)
- Sublime Text 2 (6)
- Sublime Text 3 (3)
- Vim (3)
- 連線工具 (1)
- Xshell (1)
- Adobe (1)
- 程式語言 (79)
- CSS (2)
- HTML (2)
- iOS (1)
- Java (30)
- JavaScript (5)
- jQuery (4)
- jsTree (2)
- JSP (3)
- PHP (16)
- Python (7)
- Ruby (1)
- sed (1)
- Shell Script (8)
- Windows Bash Script (1)
- XML (1)
- 資料庫 (37)
- FFMpeg (5)
Category Archives: Nginx
Xibo & Nginx-rtmp
20141226 更新 不要用這個~~因為不穩定~Orz 環境: Ubuntu 14.04.01 1. 安裝build deb需要的套件
1 |
apt-get install dpkg-dev |
創建source code目錄
1 2 |
mkdir -p /usr/src/nginx cd /usr/src/nginx |
透過apt-get下載nginx的source code
1 |
apt-get source nginx |
安裝git
1 |
apt-get install git |
透過git下載nginx-rtmp-module的source code
1 |
git clone https://github.com/arut/nginx-rtmp-module.git |
將rtmp、xlst模組功能加入設定檔中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
cd nginx-1.4.6/ vim debian/rules <略> common_configure_flags := --with-cc-opt="$(debian_cflags)" --with-ld-opt="$(debian_ldflags)" --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_xslt_module --add-module=/usr/src/nginx/nginx-rtmp-module <略> |
安裝nginx的相依性套件
1 |
apt-get build-dep nginx |
建置nginx deb
1 |
dpkg-buildpackage -b |
安裝編譯後的檔案
1 |
dpkg --install nginx-common_1.4.6-1ubuntu3.1_all.deb nginx-full_1.4.6-1ubuntu3.1_amd64.deb |
安裝php5-fpm、mysql-server、php5-mysql
1 |
apt-get install php5-fpm php5-mysql mysql-server |
修改nginx default site設定,加入php功能及相關host
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
vim /etc/nginx/sites-available/default server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name xibo; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests #location /RequestDenied { # proxy_pass http://127.0.0.1:8080; #} error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ .php$ { fastcgi_split_path_info ^(.+.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } location /obs-remote { root html; index index.html index.htm; #allow #deny all; #auth_basic "Restricted Area"; #auth_basic_user_file /usr/local/nginx/conf/.htpasswd; } location /stat { rtmp_stat all; # Use this stylesheet to view XML as web page # in browser rtmp_stat_stylesheet stat.xsl; #auth_basic "Restricted Area stat"; #auth_basic_user_file /usr/local/nginx/conf/.htpasswd; } location /stat.xsl { # XML stylesheet to view RTMP stats. # Copy stat.xsl wherever you want # and put the full directory path here root html; # auth_basic "Restricted Area stat.xsl"; # auth_basic_user_file /usr/local/nginx/conf/.htpasswd; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /.ht { # deny all; #} } |
修改nginx設定,加入rtmp模組
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
vim /etc/nginx/nginx.conf rtmp { server { listen 1935; chunk_size 4096; application live { live on; record off; #allow publish 10.0.0.0/8; #deny publish all; #allow play 10.201.80.107; #deny play all; } } } |
重新啟動
1 |
service nginx restart |
Posted in Nginx, Ubuntu, Xibo
Leave a comment
Nginx Proxy Setting…
因為 wisemapping 預設使用 8080 port etherpad 預設使用 9001 port 都很麻煩~~所以就使用 nginx proxy 幫忙轉址了 以下是測試很久的設定檔
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
location /pad { rewrite ^/pad(/.*)$ $1 break; proxy_pass http://localhost:9001/; proxy_set_header Host $host; proxy_buffering off; access_log /var/log/nginx/etherpad.log; error_log /var/log/nginx/etherpad.log; } location /map { #rewrite ^/map(/.*)$ $1 break; proxy_pass http://localhost:8080/map; proxy_set_header Host $host; proxy_buffering off; access_log /var/log/nginx/wisemapping.log; error_log /var/log/nginx/wisemapping.log; } |
配合這個設定 etherpad 需要設定 {etherpad home directory}/settings.json
1 2 3 4 5 6 7 |
//略 //IP and port which etherpad should bind at "ip": "127.0.0.1", "port" : 9001, /*when you use NginX or another proxy/ load-balancer set this to true*/ "trustProxy": true, //略 |
wisemapping 要設定的地方比較多…. {wisemapping home directory}/webapps/wisemapping/WEB-INF/app.properties
1 2 3 4 5 |
<略> site.baseurl = http://{伺服器IP}/map <略> documentation.services.basePath=http://{伺服器IP}/map/service <略> |
{wisemapping home directory}/contexts/wisemapping.xml
1 2 3 4 5 |
<略> <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <略> <Set name="contextPath">/map</Set> <略> |
Posted in etherpad, Nginx, Wisemapping
Leave a comment
Git Server 安裝 (New)
OS: Ubuntu 14.04 Server x64 安裝Gitlab + MySQL + Nginx 系統更新
1 2 3 |
apt-get update apt-get upgrade -y apt-get dist-upgrade |
安裝基本需求
1 2 3 |
# 記得要先裝vim update-alternatives --set editor /usr/bin/vim.basic sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate cmake |
安裝python
1 2 3 4 5 6 7 8 9 10 11 12 |
sudo apt-get install -y python python --version python2 --version # 確認 python版本,如果版本是3.x以上,則需額外安裝2.x版 # sudo apt-get install -y python2.7 # python --version # Python 2.7.3 # python2 --version # 命令執行會採用 python2, 所以需要確認 python2 的版本 # python2 不存在的話, 需要把 python 2.7 版 的 ln 過去. # sudo ln -s /usr/bin/python /usr/bin/python2 apt-get install -y python-docutils |
安裝Git
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# 檢查Git目前可apt安裝的版本 apt-cache showpkg git-core # 如果版本大於1.7.10,則可以直接使用~否則建議手動安裝新版本 # 直接安裝 => apt-get install -y git-core # 如果原本就安裝舊有版本,移除 => apt-get remove git-core # 手動安裝Git apt-get install -y libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev build-essential cd /tmp curl --progress https://git-core.googlecode.com/files/git-1.9.0.tar.gz | tar xz cd git-1.9.0/ make prefix=/usr/local all make prefix=/usr/local install |
安裝Ruby
1 2 3 4 5 6 7 8 9 10 11 12 |
# 如果裝有1.8版,先行移除 # apt-get remove ruby1.8 mkdir /tmp/ruby && cd /tmp/ruby curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p481.tar.gz | tar xz cd ruby-2.0.0-p481/ ./configure --disable-install-rdoc # 下面這行可以用 make 就好 make -j `cat /proc/cpuinfo | grep 'cpu cores' | awk '{if ($4=1) print $4; else print $4-1}'` make install gem install bundler --no-ri --no-rdoc |
新增Gitlab系統帳號
1 |
adduser --disabled-login --gecos 'GitLab' git |
安裝GitLab Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
cd /home/git sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git cd gitlab-shell # 查看最新版本為何 # 或是使用 sudo -u git -H git checkout `sudo -u git -H git describe --abbrev=0 --tags` 自動判斷安裝最新版 sudo -u git -H git tag sudo -u git -H git checkout v2.1.0 sudo -u git -H cp config.yml.example config.yml #修改gitlab_url,改成要使用的domain sudo -u git -H editor config.yml sudo -u git -H ./bin/install |
安裝MySQL Database
1 2 3 4 5 6 7 8 9 |
apt-get install -y mysql-server mysql-client libmysqlclient-dev mysql -u root -p #修改密碼 > CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'GITLAB_PASSWORD'; > CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; >GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; # 使用gitlab帳號測試MySQL sudo -u git -H mysql -u gitlab -p -D gitlabhq_production |
安裝GitLab
1 2 3 4 5 6 7 8 9 10 |
cd /home/git sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab cd /home/git/gitlab # 檢查版本,找stable的 # 或是使用下面自動判斷最新且stable的版本進行安裝 # sudo -u git -H git checkout `sudo -u git -H git branch -a | grep 'stable' | awk 'E ND{print}' | awk 'split($1, version, "/") {print version[3]}'` sudo -u git -H git branch -a sudo -u git -H git checkout 7-0-stable |
設定GitLab
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
cd /home/git/gitlab sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml # 所有 localhost 改成要使用的domain. # /usr/bin/git 改成 /usr/local/bin/git sudo -u git -H editor config/gitlab.yml #調整檔案權限 chown -R git log/ chown -R git tmp/ chmod -R u+rwX log/ chmod -R u+rwX tmp/ sudo -u git -H mkdir /home/git/gitlab-satellites sudo -u git -H mkdir tmp/pids/ sudo -u git -H mkdir tmp/sockets/ chmod -R u+rwX tmp/pids/ chmod -R u+rwX tmp/sockets/ sudo -u git -H mkdir public/uploads chmod -R u+rwX public/uploads sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb chmod -R u+rwX public/uploads sudo -u git -H mkdir public/uploads #如果硬體記憶體規格超過2G,可將worker_processes改成3 #sudo -u git -H editor config/unicorn.rb sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb sudo -u git -H git config --global user.name "GitLab" sudo -u git -H git config --global user.email "gitlab@localhost" sudo -u git -H git config --global core.autocrlf input |
GitLab DB設計
1 2 3 4 5 6 |
sudo -u git cp config/database.yml.mysql config/database.yml # 將production區塊的secure password值改成MySQL gitlab帳號設定的帳號、密碼 sudo -u git -H editor config/database.yml sudo -u git -H chmod o-rwx config/database.yml |
安裝Gems
1 2 |
cd /home/git/gitlab sudo -u git -H bundle install --deployment --without development test postgres aws |
初始化 Database
1 2 3 4 5 6 |
# 問啥就輸入yes以便建立Database sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production # 取得系統預設帳號、密碼 (所有新安裝都一樣,務必要更改) Administrator account created: login.........admin@local.host password......5iveL!fe |
Posted in Git, Nginx, Ubuntu
Leave a comment
Nginx SSL Enable
環境: Ubuntu 14.04 x64 產生key
1 2 3 4 5 6 7 |
root@Wordpress:/tmp# openssl genrsa -des3 -out site.key 2048 Generating RSA private key, 2048 bit long modulus ..........................+++ ....................................+++ e is 65537 (0x10001) Enter pass phrase for site.key: Verifying - Enter pass phrase for site.key: |
2.產生 csr
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
root@Wordpress:/tmp# openssl req -new -key site.key -out site.csr Enter pass phrase for site.key: You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:TW State or Province Name (full name) [Some-State]:Taiwan Locality Name (eg, city) []:Taipei City Organization Name (eg, company) [Internet Widgits Pty Ltd]:Cowman Organizational Unit Name (eg, section) []:IT Common Name (e.g. server FQDN or YOUR name) []:cowman.ip Email Address []:cowman.chiang@gmail.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: |
cat csr,貼至申請處
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
root@Wordpress:/tmp# cat site.csr -----BEGIN CERTIFICATE REQUEST----- MIIC1DCCAbwCAQAwgY4xCzAJBgNVBAYTAlRXMQ8wDQYDVQQIDAZUYWl3YW4xFDAS BgNVBAcMC1RhaXBlaSBDaXR5MQ8wDQYDVQQKDAZDb3dtYW4xCzAJBgNVBAsMAklU MRIwEAYDVQQDDAljb3dtYW4uaXAxJjAkBgkqhkiG9w0BCQEWF2Nvd21hbi5jaGlh bmdAZ21haWwuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2oNl FGzEzzpVSvFkwrYegC1VxoznmsPp2UrImb+w2M4ZLLuqdAqjhLs1atnPaQZsQlOF wfbnbGvcdwULuIzU8o1o1v7KS7TmWfi7P3oYG5GBRq/j3QuOQEwQ1s0QFAnulso9 rAHCt4i1rFg8wNF6mEF1Ghd2DzzD8P7Ew+LCYq+C4G8yq44RD+WJ8DccA4OQfzou mcstrRkXWmoYyrICepCE4eqxSdlNH3dyZbSmG4yKC1gQc60/Utm5o8lGynvS0pBh PUx124eMsWz80wZ0xAkE6Ma24XgOHied3XuaiRfBi5/tql+wfEQBrIOZ0DJ1DAhN J723zUMw9amQ8cF4zQIDAQABoAAwDQYJKoZIhvcNAQELBQADggEBAGeLtDAWlgh6 ag+PP8YqXrxGSAkkyL8EKdrPEntgYEPIkKt9to+h0tKBCZ5kCvG4bL6V5zRhtx4f ViqTzh9itOI3MDfvE5o8vxhed4jzevIifpKDONt0bAOC73STpv9+HCR+CMNX0Erf tmhD+zuLwHcBl5qoZqaPQobPF1VR1U2jsGBZ2HTTamtjGcr0mkso3MO5QxcV8JkP DwAc/PGn06zzKUyPeGPY2PE2xAppcof8B/WOYLvRx202YeoG6Cp1hLT94GoN+ef/ aDwd7WgaFpC1sXTnjoOlzpsxoovHmaJMTskncYkUZIsg4ZvhJnF9trqu9XlUKBh7 vDAfX3ZNzCs= -----END CERTIFICATE REQUEST----- |
這裡一樣以namecheap的comodo ssl為例,會收到下面四個檔案 伺服器類型選nginx AddTrustExternalCARoot.crt COMODORSAAddTrustCA.crt COMODORSADomainValidationSecureServerCA.crt cowman_ip.crt 產生 ssl-bundle.crt
1 |
cat cowman_ip.crt COMODORSAAddTrustCA.crt COMODORSADomainValidationSecureServerCA.crt AddTrustExternalCARoot.crt >> ssl-bundle.crt |
移除需要輸入 phase 的機制
1 2 3 |
root@Wordpress:/tmp# openssl rsa -in site.key -out site-nopass.key Enter pass phrase for site.key: writing RSA key |
修改 nginx 設定檔,位置在 /etc/nginx/sites-enabled/default,這裡把設定檔整併在server中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
root@Wordpress:/tmp# vim /etc/nginx/sites-enabled/default server { #listen 80 default_server; #listen [::]:80 default_server ipv6only=on; listen 80; listen 443 default ssl; ssl_certificate /opt/local/nginx/conf/certs/ssl-bundle.crt; ssl_certificate_key /opt/local/nginx/conf/certs/site_ip.key; ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES"; ssl_prefer_server_ciphers on; |
重新啟動 nginx
1 |
service nginx restart |
Posted in Nginx, SSL, Ubuntu
Leave a comment
CentOS 快速安裝 Nginx with RTMP module
跟 之前裝在Ubuntu的那一篇 一樣 都是沒有設定stat的部分, 需要在另外修改 大致上跟Ubuntu的方式都相同 只是要注意的為 init script 可不可正常進行 測試的範例中是修改 nginx.conf 將 pid 那一行給取消註腳
1 |
pid logs/nginx.pid; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#!/bin/sh yum groupinstall 'Development Tools' -y yum install pcre pcre-devel openssl-devel libxslt-devel -y cd /tmp wget http://nginx.org/download/nginx-1.7.3.tar.gz wget https://github.com/arut/nginx-rtmp-module/archive/master.zip tar -zxvf nginx-1.7.3.tar.gz yum install unzip -y unzip master.zip cd nginx-1.7.3/ ./configure --with-http_ssl_module --with-http_xslt_module --add-module=../nginx-rtmp-module-master make make install cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak echo " " >> /usr/local/nginx/conf/nginx.conf echo "rtmp {" >> /usr/local/nginx/conf/nginx.conf echo " server {" >> /usr/local/nginx/conf/nginx.conf echo " listen 1935;" >> /usr/local/nginx/conf/nginx.conf echo " chunk_size 4096;" >> /usr/local/nginx/conf/nginx.conf echo " " >> /usr/local/nginx/conf/nginx.conf echo " application live {" >> /usr/local/nginx/conf/nginx.conf echo " live on;" >> /usr/local/nginx/conf/nginx.conf echo " record off;" >> /usr/local/nginx/conf/nginx.conf echo " #allow publish 127.0.0.1;" >> /usr/local/nginx/conf/nginx.conf echo " #deny publish all;" >> /usr/local/nginx/conf/nginx.conf echo " #allow play 127.0.0.1;" >> /usr/local/nginx/conf/nginx.conf echo " #deny play all;" >> /usr/local/nginx/conf/nginx.conf echo " }" >> /usr/local/nginx/conf/nginx.conf echo " }" >> /usr/local/nginx/conf/nginx.conf echo "}" >> /usr/local/nginx/conf/nginx.conf # 這邊直接使用放在網站上的檔案 # 請複製 http://wiki.nginx.org/RedHatNginxInitScript 中的檔案至 nignx 中 cd /etc/init.d/ vim nginx chmod +x nginx service nginx start # service nginx start|stop|reload |
Posted in CentOS, Nginx, RTMP
Leave a comment
Nginx RTMP Module Stat
將 RTMP 模組檔案解壓縮後的 stat.xsl 複製到網頁目錄
1 2 3 |
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip unzip master.zip cp nginx-rtmp-module-master/stat.xsl /usr/local/nginx/html/. |
編輯 Nginx 設定檔,加入 stat 網頁設定
1 2 3 4 5 6 7 8 |
location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root html; } |
重新讀取設定檔 連結網頁 http://[ip]/stat 參考 : https://github.com/arut/nginx-rtmp-module
Posted in Nginx, RTMP
Leave a comment
Nginx 存取設定 – http_auth_basic_module
編輯檔案 /usr/local/nginx/conf/nginx.conf for http 模組
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
location / { satisfy any; # satisfy 滿足條件 # satisfy [all | any] # satisfy all => 下列條件都要滿足 # satisfy any => 下列條件只要任一滿足就可以 # 此處用到 http_access_module 及 http_auth_basic_module 兩個 # 所以設定為any~任一滿足即可 root html; index index.html index.htm; # ngx_http_access_module # 允許 10.201.80.107 瀏覽 allow 10.201.80.107; # 其它來源不允許瀏覽 deny all; # 其它來源使用帳密取得權限 # ngx_http_auth_basic_module auth_basic "Restricted Area"; # 設定跳出輸入帳號、密碼視窗的標題 auth_basic_user_file /usr/local/nginx/conf/.htpasswd; # 設定user file位置為/usr/local/nginx/conf/.htpasswd } |
安裝 apache2-utils
1 |
apt-get install apache2-utils |
產生 htpasswd 檔案
1 2 3 4 5 6 |
# 第一次請加 -c # htpasswd -c [user file位置] [帳號] htpasswd -c /usr/local/nginx/conf/.htpasswd tdg # 非第一次使用不加 -c # htpasswd [user file位置] [帳號] htpasswd /usr/local/nginx/conf/.htpasswd tdg |
reload nginx conf就可以了~
Posted in Nginx
Leave a comment
Nginx 存取設定
檔案 /usr/local/nginx/conf/nginx.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#在 http 模組下 location / { root html; index index.html index.htm; # allowed ip list allow 192.168.0.0/24; #deny ip list deny all; } location /obs-remote { root html; index index.html index.htm; # allowed ip list allow 192.168.0.0/24; #deny ip list deny all; } #在 rtmp 模組下 application live { live on; record off; # allow publish streaming allow publish 192.168.0.0/24; # deny publish streaming deny publish all; # allow play allow play 192.168.0.0/24; # deny play deny play all; |
修改後,執行 service nginx reload 重 load 設定檔 這邊都是設定 192.168.0.0/24 的 Lan 內才能觀看
Posted in Nginx
Leave a comment
Ubuntu x64 快速安裝 Nginx with RTMP module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#!/bin/sh apt-get install build-essential libpcre3 libpcre3-dev libssl-dev libxslt-dev -y cd /tmp wget http://nginx.org/download/nginx-1.7.3.tar.gz wget https://github.com/arut/nginx-rtmp-module/archive/master.zip tar -zxvf nginx-1.7.3.tar.gz apt-get install unzip -y unzip master.zip cd nginx-1.7.3/ ./configure --with-http_ssl_module --with-http_xslt_module --add-module=../nginx-rtmp-module-master make make install cp /tmp/nginx-rtmp-module-master/stat.xsl /usr/local/nginx/html/ cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak echo " " >> /usr/local/nginx/conf/nginx.conf echo "rtmp {" >> /usr/local/nginx/conf/nginx.conf echo " server {" >> /usr/local/nginx/conf/nginx.conf echo " listen 1935;" >> /usr/local/nginx/conf/nginx.conf echo " chunk_size 4096;" >> /usr/local/nginx/conf/nginx.conf echo " " >> /usr/local/nginx/conf/nginx.conf echo " application live {" >> /usr/local/nginx/conf/nginx.conf echo " live on;" >> /usr/local/nginx/conf/nginx.conf echo " record off;" >> /usr/local/nginx/conf/nginx.conf echo " #allow publish 127.0.0.1;" >> /usr/local/nginx/conf/nginx.conf echo " #deny publish all;" >> /usr/local/nginx/conf/nginx.conf echo " #allow play 127.0.0.1;" >> /usr/local/nginx/conf/nginx.conf echo " #deny play all;" >> /usr/local/nginx/conf/nginx.conf echo " }" >> /usr/local/nginx/conf/nginx.conf echo " }" >> /usr/local/nginx/conf/nginx.conf echo "}" >> /usr/local/nginx/conf/nginx.conf # 這邊請複製 http://wiki.nginx.org/Nginx-init-ubuntu 內容至 nginx 檔案中 cd /etc/init.d/ vim nginx chmod +x nginx service nginx start # service nginx start|stop|reload |
Posted in Nginx, Ubuntu
Leave a comment
Nginx init script (Ubuntu)
將下列內容貼到 /etc/init.d/nginx 中,並且使用 chmod +x nginx 調整屬性
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
#! /bin/sh ### BEGIN INIT INFO # Provides: nginx # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the nginx web server # Description: starts nginx using start-stop-daemon ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/sbin/nginx NAME=nginx DESC=nginx test -x $DAEMON || exit 0 # Include nginx defaults if available if [ -f /etc/default/nginx ] ; then . /etc/default/nginx fi set -e case "$1" in start) echo -n "Starting $DESC: " start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS echo "$NAME." ;; stop) echo -n "Stopping $DESC: " start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid --exec $DAEMON echo "$NAME." ;; restart|force-reload) echo -n "Restarting $DESC: " start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid --exec $DAEMON sleep 1 start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS echo "$NAME." ;; reload) echo -n "Reloading $DESC configuration: " start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid --exec $DAEMON echo "$NAME." ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0 |