nginx反向代理搭建web网站问题

搭建过程中遇到的问题记录:

1、ubuntu更改端口号

sudo vi /etc/apache2/ports.conf
  • 修改监听端口以及主机端口为8080
    NameVirtualHost *:8080
    Listen 8080
sudo vi /etc/apache2/sites-enabled/000-default.conf
  • 修改端口为8080
    <VirtualHost *:8080>
  • 重启apache2

2、apache2 前端页面目录层级太深配置方法:

多目录:

  • 先在/etc/apache2下新建一个httpd.conf配置文件
cd /etc/apache2
sudo vim httpd.conf

编辑httpd.conf内容

<VirtualHost *:80>
DocumentRoot /var/www/html/Web1
DirectoryIndex index.html
</VirtualHost>
  • 在/etc/apache2 修改 apache2.conf,添加一行:
Include httpd.conf
  • 重启 apache2 服务
sudo service apache2 restart
  • 修改/etc/apache2/sites-enabled/000-default.conf文件,配置目录指向
Alias "/api"  "/var/www/html/api/xxx"

3、nginx反向代理配置

    server {
        listen       80;
        server_name  xxx.top;
        rewrite ^(.*) https://$server_name$1 permanent;
    }

    server {
        listen       443 ssl;
        server_name  xxx.top;

        #charset koi8-r;

        #ssl
        ssl_certificate /usr/local/nginx/ssl/9393727_xxx.top.pem;
        ssl_certificate_key /usr/local/nginx/ssl/9393727_xxx.top.key;

        ssl_session_timeout  5m;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;


        #access_log  logs/host.access.log  main;

        location /api {
            proxy_pass http://127.0.0.1:9000;
        }

posted @   鱼的记忆·  阅读(77)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)
点击右上角即可分享
微信分享提示