为了账号安全,请及时绑定邮箱和手机立即绑定

Linux——CentOS7使用nginx反向代理8080端口到80端口

找到nginx.conf
[www@VM_183_120_centos ~]$ whereis nginx.conf  //先找到nginx.conf
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man3/nginx.3pm.gz /usr/share/man/man8/nginx.8.gz
[www@VM_183_120_centos ~]$ cd /etc/nginx  //根据上面找到的路径我们进入
[www@VM_183_120_centos nginx]$ ll    //查看
total 68
drwxr-xr-x 2 root root 4096 Oct 31 20:32 conf.d
drwxr-xr-x 2 root root 4096 Oct 31 20:32 default.d
-rw-r--r-- 1 root root 1077 Oct 31 20:39 fastcgi.conf
-rw-r--r-- 1 root root 1077 Oct 31 20:39 fastcgi.conf.default
-rw-r--r-- 1 root root 1007 Oct 31 20:39 fastcgi_params
-rw-r--r-- 1 root root 1007 Oct 31 20:39 fastcgi_params.default
-rw-r--r-- 1 root root 2837 Oct 31 20:39 koi-utf
-rw-r--r-- 1 root root 2223 Oct 31 20:39 koi-win
-rw-r--r-- 1 root root 3957 Oct 31 20:39 mime.types
-rw-r--r-- 1 root root 3957 Oct 31 20:39 mime.types.default
-rw-r--r-- 1 root root 2467 Oct 31 20:39 nginx.conf         //在这里
-rw-r--r-- 1 root root 2656 Oct 31 20:39 nginx.conf.default
-rw-r--r-- 1 root root  636 Oct 31 20:39 scgi_params
-rw-r--r-- 1 root root  636 Oct 31 20:39 scgi_params.default
-rw-r--r-- 1 root root  664 Oct 31 20:39 uwsgi_params
-rw-r--r-- 1 root root  664 Oct 31 20:39 uwsgi_params.default
-rw-r--r-- 1 root root 3610 Oct 31 20:39 win-utf
[www@VM_183_120_centos nginx]$ su
Password: 
[root@VM_183_120_centos nginx]# vi nginx.conf  //开始编辑配置文件
更改配置文件
 server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  127.0.0.1:8080;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
         proxy_pass   http://127.0.0.1:8080;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

然后输入nginx -s reload重启nginx ,就可以直接通过ip/域名访问8080端口了。

点击查看更多内容
6人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
全栈工程师
手记
粉丝
218
获赞与收藏
1546

关注作者,订阅最新文章

阅读免费教程

感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消