In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to solve the problem of cookie cross-domain access in nginx? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.
one
Nginx: [emerg] unknown directive "aio" in
Plus-- with-file-aio
The copy code is as follows:
Starting nginx: nginx: [emerg] the INET6 sockets are not supported on this platform in "[:]: 80" of the
Add-- with-ipv6 to the end.
After the installation is complete. Mainly the configuration of nginx.conf
The configuration nginx.conf of the original server:
?
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
twenty-one
twenty-two
twenty-three
twenty-four
twenty-five
twenty-six
twenty-seven
twenty-eight
twenty-nine
thirty
thirty-one
thirty-two
thirty-three
thirty-four
thirty-five
thirty-six
thirty-seven
thirty-eight
thirty-nine
forty
forty-one
forty-two
forty-three
forty-four
forty-five
forty-six
forty-seven
forty-eight
forty-nine
fifty
fifty-one
fifty-two
fifty-three
fifty-four
fifty-five
fifty-six
fifty-seven
fifty-eight
fifty-nine
sixty
sixty-one
sixty-two
sixty-three
sixty-four
sixty-five
sixty-six
sixty-seven
sixty-eight
sixty-nine
seventy
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
User root
Worker_processes 2
Worker_cpu_affinity 1000 0100
Error_log logs/error.log
Pid logs/nginx.pid
Events {
Worker_connections 2048
}
Http {
Log_format main'$remote_addr-$remote_user [$time_local] "$request"'
'$status $body_bytes_sent "$http_referer"'
'"$http_user_agent"$http_x_forwarded_for"'
Access_log logs/access.log main
Gzip on
Gzip_min_length 1000
Gzip_buffers 4 8k
Gzip_types text/plain application/javascript application/x-javascript text/css application/xml
Client_max_body_size 8M
Client_body_buffer_size 128k
Sendfile on
Tcp_nopush on
Tcp_nodelay on
Keepalive_timeout 65
Types_hash_max_size 2048
Include mime.types
Default_type application/octet-stream
Connection_pool_size 512
Aio on
Open_file_cache max=1000 inactive=20s
# Load modular configuration files from the / etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
# the main configuration is here, and the nginx.conf configuration is the same
Include / usr/local/nginx/conf/conf.d/*.conf
Server {
Listen 80 default_server
Listen [::]: 80 ipv6only=on default_server
Server_name _
Root html
# Load configuration files for the default server block.
Include / usr/local/nginx/conf/default.d/*.conf
Location / {
}
Error_page 404 / 404.html
Location = / 40x.html {
}
Error_page 500 502 503 504 / 50x.html
Location = / 50x.html {
}
}
}
The original server
The configuration of conf.d/*.conf is reverse-proxy.conf
?
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
twenty-one
twenty-two
twenty-three
twenty-four
twenty-five
twenty-six
twenty-seven
twenty-eight
twenty-nine
thirty
thirty-one
thirty-two
thirty-three
thirty-four
thirty-five
thirty-six
thirty-seven
thirty-eight
thirty-nine
forty
forty-one
forty-two
forty-three
forty-four
forty-five
forty-six
forty-seven
forty-eight
forty-nine
fifty
fifty-one
fifty-two
fifty-three
fifty-four
fifty-five
fifty-six
fifty-seven
fifty-eight
fifty-nine
sixty
sixty-one
sixty-two
Server
{
Listen 80
Server_name m.abc.com.cn
Location / {
Root / usr/share/nginx/html/
Index index.html index.htm
}
Location. (jsp | do)? ${
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
Proxy_pass http://localhost:8084;
}
If ($http_user_agent ~ * "qihoobot | Baiduspider | Googlebot | Googlebot-Mobile | Googlebot-Image | Mediapartners-Google | Adsbot-Google | Feedfetcher-Google | Yahoo! Slurp | Yahoo! Slurp China | YoudaoBot | Sosospider | Sogou spider | Sogou web spider | MSNBot | ia_archiver | Tomato Bot") {
Return 403
}
Access_log / home/logs/nginx/m.abc.com.cn_access.log
}
Server
{
Listen 80
Server_name store.abc.com.cn * .store.abc.com.cn
Location / {
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
Proxy_pass http://localhost:8081;
}
Access_log / home/logs/nginx/store.abc.com.cn_access.log
}
Server
{
Listen 80
Server_name shopcenter.abc.com.cn
Location / {
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
Proxy_pass http://10.45.100.222:8082;
}
Access_log / home/logs/nginx/shopcenter.abc.com.cn_access.log
}
Server
{
Listen 80
Server_name search.abc.com.cn
Location / {
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
Proxy_pass http://10.45.100.68:8083;
}
Access_log / home/logs/nginx/search.abc.com.cn_access.log
}
After the above configuration, after nginx starts, you can access different servers by accessing different domain names. And because they all have a secondary domain name, .abc.com.cn. So you can share cookie.
The file structure of nginx is:
III. Modified nginx configuration
Mainly because the reverse-proxy.conf is different.
?
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
twenty-one
twenty-two
twenty-three
twenty-four
twenty-five
twenty-six
twenty-seven
twenty-eight
twenty-nine
thirty
thirty-one
thirty-two
thirty-three
thirty-four
thirty-five
thirty-six
thirty-seven
thirty-eight
thirty-nine
forty
forty-one
forty-two
forty-three
forty-four
forty-five
forty-six
forty-seven
forty-eight
forty-nine
fifty
fifty-one
fifty-two
fifty-three
fifty-four
fifty-five
fifty-six
fifty-seven
fifty-eight
fifty-nine
sixty
sixty-one
sixty-two
sixty-three
sixty-four
sixty-five
sixty-six
sixty-seven
sixty-eight
sixty-nine
seventy
seventy-one
seventy-two
seventy-three
seventy-four
seventy-five
seventy-six
seventy-seven
seventy-eight
seventy-nine
eighty
eighty-one
eighty-two
eighty-three
eighty-four
eighty-five
eighty-six
eighty-seven
eighty-eight
eighty-nine
ninety
ninety-one
ninety-two
ninety-three
ninety-four
ninety-five
ninety-six
ninety-seven
ninety-eight
Server
{
Listen 9998
Server_name 192.168.0.1:9998
Location / servlets/ {
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
Proxy_pass http://192.168.0.1:8088;
}
Location / {
Root / usr/local/nginx/html/web/
Index index.html index.htm
}
Location. (jsp | do)? ${
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
Proxy_pass http://192.168.0.1:8088;
Proxy_http_version 1.1
Proxy_set_header Upgrade $http_upgrade
Proxy_set_header Connection "upgrade"
Proxy_read_timeout 700s
}
If ($http_user_agent ~ * "qihoobot | Baiduspider | Googlebot | Googlebot-Mobile | Googlebot-Image | Mediapartners-Google | Adsbot-Google | Feedfetcher-Google | Yahoo! Slurp | Yahoo! Slurp China | YoudaoBot | Sosospider | Sogou spider | Sogou web spider | MSNBot | ia_archiver | Tomato Bot") {
Return 403
}
Access_log / usr/local/nginx/logs/www.abc.com.cn_access.log
}
Server
{
Listen 9994
Server_name 192.168.0.1:9994
Location / {
Proxy_redirect off
Root / usr/local/nginx/html/weixin/
Index index.html index.htm
}
Location. (jsp | do)? ${
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
Proxy_pass http://localhost:8084;
}
If ($http_user_agent ~ * "qihoobot | Baiduspider | Googlebot | Googlebot-Mobile | Googlebot-Image | Mediapartners-Google | Adsbot-Google | Feedfetcher-Google | Yahoo! Slurp | Yahoo! Slurp China | YoudaoBot | Sosospider | Sogou spider | Sogou web spider | MSNBot | ia_archiver | Tomato Bot") {
Return 403
}
Access_log / usr/local/nginx/logs/m.abc.com.cn_access.log
}
Server
{
Listen 9990
Server_name store.abc.com.cn * .store.abc.com.cn
Location / {
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
Proxy_pass http://localhost:8081;
}
Access_log / usr/local/nginx/logs/store.abc.com.cn_access.log
}
Server
{
Listen 9992
Server_name 192.168.0.1:9992
Location / {
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
Proxy_pass http://192.168.0.2:8082;
}
Access_log / usr/local/nginx/logs/shopcenter.abc.com.cn_access.log
}
Server
{
Listen 9993
Server_name 192.168.0.1:9993
Location / {
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
Proxy_pass http://192.168.0.3:8083;
}
Access_log / usr/local/nginx/logs/search.abc.com.cn_access.log
}
In this way, 192.168.0.1 domain 9998 can be used as a single point server, and the login server is 192.168.0.1. The other 0.2,0.3 can be accessed through different ports of 192.168.0.1nginx and single point servers, so you can share the 0.1domain name.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Http://www.cnblogs.com/minzhousblogs/p/9023391.html
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.