2022年度最佳搬砖户 2021-04-25 10:28 采纳率: 0%
浏览 125

nginx反向代理不成功

使用ubuntu安装的,直接apt install安装的,然后安装目录是在/etc/nginx,下面有一个nginx.conf的配置文件,我在http{}里面配置了server了,具体如下

http {

	##
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	# server_tokens off;

	# server_names_hash_bucket_size 64;
	# server_name_in_redirect off;

	include /etc/nginx/mime.types;
	default_type application/octet-stream;

	##
	# SSL Settings
	##

	ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
	ssl_prefer_server_ciphers on;

	##
	# Logging Settings
	##

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	##
	# Gzip Settings
	##

	gzip on;

	# gzip_vary on;
	# gzip_proxied any;
	# gzip_comp_level 6;
	# gzip_buffers 16 8k;
	# gzip_http_version 1.1;
	# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

	##
	# Virtual Host Configs
	##

	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
	server {
        	listen       80;
	        server_name  localhost;

        	location / {
	            proxy_pass http://180.101.49.11;
        	    index  index.html index.htm index.jsp;
       		 }
   	 }

}

重点在这几行:

server {
            listen       80;
            server_name  localhost;

            location / {
                proxy_pass http://180.101.49.11;
                index  index.html index.htm index.jsp;
                }
        }

这几行的含义不就是通过访问本地端口80之后再跳转到http://180.101.49.11这个ip地址吗,我试了试不行,访问80端口还是欢迎nginx的界面,所以我想问,是我配置出错了还是怎么回事,谢谢大佬们。

  • 写回答

1条回答 默认 最新

  • yuxiaqiao 2021-04-25 17:04
    关注

    listen 80 default_server;

    nginx 默认存在/etc/nginx/sites-enabled/default 文件,默认是访问这个文件的,你需要调整一下,或者直接在这个default文件里面改。

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测