Nginx (engine x) 可作为web反向代理服务器。能够代理外部网络上的主机,访问内部网络

1 首先windows下载nginx :http://nginx.org/download/nginx-1.6.2.tar.gz

2 打开nginx.conf,将需要代理文件路径写在root中,端口设为8080:

#user  nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log 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 logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; server {
listen 8080;//端口号
server_name 127.0.0.1; #location /{
# rewrite ^(.*) https://$server_name$1 permanent;
# }
#charset koi8-r; #access_log logs/host.access.log main; location / {
root D:\lanCode\lanSVNTest;//文件路径
index index.html index.htm;
} #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 html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
server {
listen 4433 ssl;
server_name localhost; ssl_certificate server.crt;
ssl_certificate_key server.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; location / {
root html;
index index.html index.htm;
}
}
}

3 打开nginx终端输入指令,或者将nginx 指令写成批处理文件,在根目录新建statUp.bat文件写入:

@echo off
rem 如果启动前已经启动nginx并记录下pid文件,会kill指定进程
nginx.exe -s stop rem 测试配置文件语法正确性
nginx.exe -t -c conf/nginx.conf rem 显示版本信息
nginx.exe -v rem 按照指定配置去启动nginx
nginx.exe -c conf/nginx.conf

4 点击运行starUp.bat,访问  http://127.0.0.1:8080/ 即可看到反向代理页面

需要用用手机连接访问时,可先查看本机IP192.168.0.105,在手机上访问

http://192.168.0.105:8080/

nginx常用命令:

nginx -s stop       快速关闭Nginx,可能不保存相关信息,并迅速终止web服务。
nginx -s quit 平稳关闭Nginx,保存相关信息,有安排的结束web服务。
nginx -s reload 因改变了Nginx相关配置,需要重新加载配置而重载。
nginx -s reopen 重新打开日志文件。
nginx -c filename 为 Nginx 指定一个配置文件,来代替缺省的。
nginx -t 不运行,而仅仅测试配置文件。nginx 将检查配置文件的语法的正确性,并尝试打开配置文件中所引用到的文件。
nginx -v 显示 nginx 的版本。
nginx -V 显示 nginx 的版本,编译器版本和配置参数。

  

nginx简易部署的更多相关文章

  1. Flask + WSGI + Nginx 云部署

    这几天学着用flask写一些rest api,然后部署到云上.这个过程虽然网上有很多的教程,但还是遇到不少的问题! 采用flask的原因是因为它比较容易上手吧.用flask有专门restful api ...

  2. nginx上部署python web

    nginx上部署python web http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html

  3. Nginx上部署HTTPS

    Nginx上部署HTTPS依赖OpenSSL库和包含文件,即须先安装好libssl-dev,且ln -s /usr/lib/x86_64-linux-gnu/libssl.so  /usr/lib/, ...

  4. nginx服务部署 说明

    第1章 常用的软件 1.1 常用来提供静态服务的软件   Apache :这是中小型Web服务的主流,Web服务器中的老大哥,   Nginx :大型网站Web服务的主流,曾经Web服务器中的初生牛犊 ...

  5. 在nginx上部署vue项目(history模式);

    在nginx上部署vue项目(history模式): vue-router 默认是hash模式,使用url的hash来模拟一个完整的url,当url改变的时候,页面不会重新加载.但是如果我们不想has ...

  6. client和nginx简易交互过程

    # client和nginx简易交互过程- step1:client发起http请求- step2:dns服务器解析域名得到主机ip- step3:默认端口为80,通过ip+port建立tcp/ip链 ...

  7. Diango + uwsgi + nginx 项目部署(可外网访问)

    自己通过nginx uwsgi 部署django项目,查询了很多资料,遇到了很多问题,最终完成了部署,趁着心情愉悦,写个随笔,为曾像我一样苦寻解决方案的小伙伴们提供些思路. 安装Nginx: #安装n ...

  8. [Redmine] Centos5上安装Redmine3.0+nginx+thin部署

    项目管理的需要所以安装Redmine,其实wiki放在上面也不错的. 首先是安装,ruby应用第一次装,把坑记住. nginx, mysql是已经安装好的,只需要配置, 结合nginx的部署方式很多, ...

  9. 填坑!!!virtualenv 中 nginx + uwsgi 部署 django

    一.为什么会有这篇文章 第一次接触 uwsgi 和 nginx ,这个环境搭建,踩了太多坑,现在记录下来,让后来者少走弯路. 本来在 Ubuntu14.04 上 搭建好了环境,然后到 centos7. ...

随机推荐

  1. LNMP+HAProxy+Keepalived负载均衡 - 基础服务准备

    日志服务 修改日志服务配置并重启日志服务: ``` vim /etc/rsyslog.conf ``` 编辑系统日志配置,指定包含的配置文件路径和规则: ``` $IncludeConfig /etc ...

  2. phpstorm 安装XeDbug

    第一步:根据phpinfo()下载相对应的Xdebug插件,Xdebug下载路径https://xdebug.org/download.php 第二步:将下载好的Xdebug放到 G:\Service ...

  3. 生产-消费模式的synchronized和lock实现(十)

    lock: package com.net.thread.lock; import java.util.concurrent.locks.Condition; import java.util.con ...

  4. ospf几种lsa

    ospf网络类型 1.点到点 点到点网段 2.广播网络 transit网段(至少有两台路由器的广播型网段) 3.NBMA transit网段 4.点到多点 ospf网段的类型(网段的类型只与网络的类型 ...

  5. ubuntu安装wine 和sourceinsght

    ubuntu安装wine: 1.sudo apt-get update 2.sudo apt-get install wine 安装完成后会在当前用户目录的的家目录下生成.wine目录,该目录就是wi ...

  6. E - Nature Reserve CodeForces - 1059D

    传送门 There is a forest that we model as a plane and live nn rare animals. Animal number iihas its lai ...

  7. POJ 1286 Pólya定理

    Necklace of Beads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9162   Accepted: 3786 ...

  8. B1091 N-自守数 (15分)

    B1091 N-自守数 (15分) 如果某个数 \(K\)的平方乘以\(N\) 以后,结果的末尾几位数等于 \(K\),那么就称这个数为"\(N\)-自守数".例如 \(3×92 ...

  9. 关于SSM框架项目中jsp页面EL表达式使用的一些疑问(一)

    问题 ssm框架整合中,jsp页面中EL表达式所引用的对象“page”可以在controller中使用mav.addObject(“page”,pag )进行添加,如果省略mav.addObject( ...

  10. python-8错误调试测试

    1-错误处理 import logging try: print('try.......') r = 10/0 except ValueError as e: print('result:', e) ...