Deployment and release of nginx + mongrel + rails 3.0 + windows

Source: Internet
Author: User
Tags microsoft website

Even though we do not advocate rails development in windows, we do not advocate rails deployment in windows ....

However, this requirement exists in a project. Since platform factors cannot be ignored, we have to go against the sky...

 

Ideas:Nginx front-end implementation (some people say that nginx is not stable in windows and may encounter various strange problems, Khan ~~), Provides SSL one-way and two-way authentication (different authentication methods for different clients ...), Provides static pages, images, JS, and CSS files, and other proxies to the backend mongrel. (Some features are not implemented and are also released in the developmen mode)

Mongrel backend server (Why does passphrase not have a Windows Version? mongre_rails does not support rails 3.0 yet. It feels terrible when you try it)

 

Steps:1. Install mongrel

2. Start the rails registration service for mongrel

3. Download nginx and register the service

4. Configure nginx to implement SSL single-way authentication and proxy Functions

 

1. Install mongrel

 
Gem install mongrel

 

2. Start the rails registration service for mongrel

1. Download two Microsoft tools: instsrv.exe?srvany.exe. For details, refer3. Download nginx and register the service

2. Write a rails. BAT file for the rails startup. The content is as follows:

 
Cd d: \ web_app \ svnmsc: \ ruby187 \ bin \ rails s-p 3003-B 127.0.0.1

#-B 127.0.0.1 is only bound to 127.0.0.1. Only local access is allowed. Because the front-end nginx is also running on the local machine, it means that only nginx is run for direct access, and external users can only access it through nginx.

3. register the service for rails. bat. For details, refer3. Download nginx and register the service

4.The content of the svnms. reg file is as follows:

 
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ svnms] "Description" = "SVN manager sysetem: D: \ webapp \ svns \ rails s-e development "" displayname "=" svnms "[HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ svnms \ Parameters]" application "=" d: \ web_app \ rails. bat "" appparameters "=" "appdirectory" = "D: \ web_app \ svnms"

3. Download nginx and register the service

1. Download nginx Windows Version http://www.nginx.org

2. Download two Microsoft tools: instsrv.exe1_srvany.exe
Go to the Microsoft website to download and install Windows Server 2003 Resource Kit tools(rktools.exe), which includes all the necessary tools mentioned in the title.

3. Run the command
You can find these two files under the rktools installation directory (generally in the c: \ Program Files \ Windows resource kits \ tools directory ).ProgramBefore running the following command, copy instsrv.exew.srvany.exe to the nginx installation (decompression) directory and run:

 
Instsrv nginx c: \ nginx \ srvany.exe # register a service

3. Edit an nginx. reg file under c: \ nginx \.

 
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ nginx \ Parameters] "application" = "C: \ nginx \ nginx.exe "" appparameters "=" appdirectory "=" C: \ nginx \\"

Parameter description: absolute path of the application: EXE or BAT file
Appparameters: Running Parameters
Appdirectory: working directory, which is the current directory at work

4. Associate services with programs and execute commands

Regedit/s nginx. Reg

5. Edit the startup nginx script start-nginx.bat (close the script without changing) to run the program as a service

 
@ Echo off net stop nginx Net start nginx exit

6. delete a service

 
SC Delete svnms

 

Supplement:However, when the nginix service is stopped, you can still see the website in the browser. Check the process and you will find that nginx has started two nginx processes (according to the nginx. conf configuration worker_processes, the process from fork is obviously not stopped, and the result is that nginx will never be shut down. Therefore, use the taskkill command to completely disable nginx:

Taskkill/f/IM nginx.exe> NUL

The result is to write a stop_nginx script to process all the operations stopped by nginx.

 
@ Echo off echo stopping nginx service... net stop nginx echo kill nginx process... taskkill/f/IM nginx.exe> NUL

 

4. Configure nginx to implement SSL single-way authentication and proxy Functions

 server {Listen 8083; SERVER_NAME liuwm-pc@grandsoft.com.cn; root D:/www-Date/Public; location/{root D:/web_app/svnms/public; # proxy 
Proxy_set_header host $ HOST: 8083; proxy_set_header X-real-IP $ remote_addr; proxy_set_header X-forwarded-for $ remote_addr; proxy_pass http: // 127.0.0.1: 3003 /; proxy_set_header X-forwarded-Proto HTTPS; proxy_redirect off;} # SSL on; ssl_certificate E:/nginx/nginx-1.1.7/SSL/server. CRT; ssl_certificate_key E:/nginx/nginx-1.1.7/SSL/server_no.key; ssl_client_certificate E:/nginx/nginx-1.1.7/SSL/CA. CRT; error_page 500 502 503 504/50 x.html; location =/50x.html {root HTML ;}}

Refer:Nginx + mongrel configuration in Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.