相同Ip 不同端口配置Nginx反向代理Apache
2014-07-28 23:04
1216 查看
相同Ip 不同端口 配置Nginx反向代理Apache(就是Nginx跳转到Apache)
在linux 一经搭建好环境 先后安装了Nginx 和Apache 由于 默认端口都是:80
一般客户请求的服务器端口默认为80 所以Nginx作为静态页端口设置:80
Apache设置端口为:8080(在httpd.conf 文件中修改Listen:8080)
如何跳转:
在nginx.conf中 添加
server {
listen 80;
server_name localhost;
}位置并列的
然后重新启动服务器 浏览器输入http://202.85.224.166:80; 看看是不是跳到Apache htdocs/index.html 页面 而不是nginx的欢迎页面
如果Apache重启失败怎么办?
1查看端口 lsof -i:80
2关闭占用80端口的所有程序如
kill -9 5031
kill -9 5032
可能不止一个
3 然后重新启动Apache
apache重新启动命令:
/usr/local/apache2/bin/apachectl restart 重启
linux kill用法、killall、pkill、xkill区别 http://www.2cto.com/os/201202/118483.html
基本的操作方法:
本文假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况
apahce启动命令:
推荐/usr/local/apache2/bin/apachectl start
apaceh启动
apache停止命令
/usr/local/apache2/bin/apachectl stop 停止
apache重新启动命令:
/usr/local/apache2/bin/apachectl restart 重启
要在重启 Apache 服务器时不中断当前的连接,则应运行:
/usr/local/sbin/apachectl graceful
如果apache安装成为linux的服务的话,可以用以下命令操作:
service httpd start 启动
service httpd restart 重新启动
service httpd stop 停止服务
Linux系统为Ubuntu
一、Start Apache 2 Server /启动apache服务
# /etc/init.d/apache2 start
or
$ sudo /etc/init.d/apache2 start
二、 Restart Apache 2 Server
/重启apache服务
# /etc/init.d/apache2 restart
or
$ sudo /etc/init.d/apache2 restart
三、Stop Apache 2 Server /停止apache服务
# /etc/init.d/apache2 stop
or
$ sudo /etc/init.d/apache2 stop
在linux 一经搭建好环境 先后安装了Nginx 和Apache 由于 默认端口都是:80
一般客户请求的服务器端口默认为80 所以Nginx作为静态页端口设置:80
Apache设置端口为:8080(在httpd.conf 文件中修改Listen:8080)
如何跳转:
在nginx.conf中 添加
location / { proxy_pass http://202.85.224.166:8080; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 这个两句的作用是将客户端ip转发给apache服务器,就是apache获得nginx服务器客户端的ip 是真是的用户ip. 好处是不用安装apache的扩展包 mod_rpaf-0.6.tar.gz 了。很是方便。避免了编译出错也释放了资源。
他们叫他:Nginx和Apache共存环境下apache获得真实IP
代码与server {
listen 80;
server_name localhost;
}位置并列的
然后重新启动服务器 浏览器输入http://202.85.224.166:80; 看看是不是跳到Apache htdocs/index.html 页面 而不是nginx的欢迎页面
如果Apache重启失败怎么办?
1查看端口 lsof -i:80
2关闭占用80端口的所有程序如
kill -9 5031
kill -9 5032
可能不止一个
3 然后重新启动Apache
apache重新启动命令:
/usr/local/apache2/bin/apachectl restart 重启
linux kill用法、killall、pkill、xkill区别 http://www.2cto.com/os/201202/118483.html
基本的操作方法:
本文假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况
apahce启动命令:
推荐/usr/local/apache2/bin/apachectl start
apaceh启动
apache停止命令
/usr/local/apache2/bin/apachectl stop 停止
apache重新启动命令:
/usr/local/apache2/bin/apachectl restart 重启
要在重启 Apache 服务器时不中断当前的连接,则应运行:
/usr/local/sbin/apachectl graceful
如果apache安装成为linux的服务的话,可以用以下命令操作:
service httpd start 启动
service httpd restart 重新启动
service httpd stop 停止服务
Linux系统为Ubuntu
一、Start Apache 2 Server /启动apache服务
# /etc/init.d/apache2 start
or
$ sudo /etc/init.d/apache2 start
二、 Restart Apache 2 Server
/重启apache服务
# /etc/init.d/apache2 restart
or
$ sudo /etc/init.d/apache2 restart
三、Stop Apache 2 Server /停止apache服务
# /etc/init.d/apache2 stop
or
$ sudo /etc/init.d/apache2 stop
相关文章推荐
- 使用nginx反向代理到不同服务器(共享同一端口)配置文件
- Nginx配置二级目录反向代理本机不同端口
- Tomcat捕获Nginx反向代理协议IP及端口配置
- nginx做代理IP端口转发的安装和部署配置
- Nginx反向代理Apache的情况下让Apache获得真实IP
- nginx 配置ip端口访问不同目录
- Apache配置同一IP不同端口映射
- nodejs使用nginx端口转发,端口映射,反向代理,子域名映射到不同端口
- nginx代理同一ip,不同端口,域名服务
- Nginx配置实现同一域名下 同一ip 通过子域名访问不同端口
- Apache同IP不同端口虚拟主机配置。
- centOS下的nginx1.8.0多站点配置(同一IP,不同端口)
- Nginx前端设置反向代理,后端Apache如何获取访客的真实IP,结合PHP
- Nginx和Apache服务器上配置反向代理
- nginx apache 配置反向代理服务器
- 反向代理概念以及apache,nginx配置反向代理实现负载均衡方法
- nginx+apache单IP多站点反向代理配置
- Nginx配置二级目录/路径 映射不同的反向代理和规避IP+端口访问
- nginx 反向代理apache服务器 配置java与PHP共存环境