ubuntu中如何使用nginx監(jiān)聽80端口進(jìn)行轉(zhuǎn)發(fā)
ubuntu使用nginx監(jiān)聽80端口進(jìn)行轉(zhuǎn)發(fā)
安裝nginx
sudo apt-get install nginx
配置路徑
nginx的默認(rèn)安裝路徑在/usr/local/nginx下.
nginx的默認(rèn)配置在/etc/nginx下.
把80端口指向8080端口, 方法如下:
include /etc/nginx/conf.d/*.conf; #include /etc/nginx/sites-enabled/*; // server { listen 80; server_name localhost; location / { proxy_pass http://127.0.0.1:8080; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; } }
簡單命令
sudo service nginx start #啟動 sudo service nginx stop #停止 sudo service nginx restart #重新啟動 sudo service nginx reload #重新啟動 sudo nginx -s start #啟動 sudo nginx -s stop #停止 sudo nginx -s restart #重新啟動 sudo nginx -s reload #重新加載配置
nginx在配置監(jiān)聽80端口不生效問題
nginx安裝之后在/etc/nginx/nginx.conf配置文件引用其它文件的配置,
如果有的話需要注釋掉,因為引用了一個默認(rèn)80端口配置,所以在nginx.conf文件配置的80端口會不起作用,所以導(dǎo)致你在nginx.conf配置80端口,怎么訪問 都是nginx默認(rèn)頁面
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
解決nginx報錯信息 client intended to send too large body: 1331696
這篇文章主要介紹了解決nginx報錯 client intended to send too large body: 1331696 bytes的相關(guān)資料,需要的朋友可以參考下2017-02-02實現(xiàn)nginx&php服務(wù)器配置的非主流配置方法
這種方法并非以前所流行的apache 加 php_module 的方式運行,我是采用nginx 作為web服務(wù)器,以fastcgi的方式運行php2011-05-05Nginx中使用Lua腳本與圖片的縮略圖處理的實現(xiàn)
本文主要介紹了Nginx中使用Lua腳本與圖片的縮略圖處理的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-03-03