nginx无法将80端口转发到其他端口的解决方案

解决方案就是:

nginx只针对/etc/nginx/nginx.conf的配置文件起作用

不要在/etc/nginx/conf.d文件夹下创建针对不同web服务的conf文件,而是直接在/etc/nginx文件夹下修改nginx.conf (最好将原先的保存一份为nginx.conf.back)

将8880端口的服务转发到80端口上:

复制代码
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        access_log   /var/log/mbook-access.log;
        error_log    /var/log/mbook-error.log;

        location / {
            proxy_pass                 http://127.0.0.1:8880;
            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;
        }
    }
}
复制代码

 

posted @   luxiayuai  阅读(441)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 我与微信审核的“相爱相杀”看个人小程序副业
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· spring官宣接入deepseek,真的太香了~
点击右上角即可分享
微信分享提示